-1

让我们的 Android 应用程序完全透明(好像它根本不活动)并在其他应用程序上工作是否可行?

我的要求:

首先最后一个应用程序,经过一些设置,使其透明。一旦透明,用户将不知道此应用程序处于活动状态,但是,我们的应用程序应仅响应特定控件。

这是因为广播接收器的限制,我将不得不在我的应用程序中使用音量按钮来执行某些操作。但是,这个按钮不广播。所以,目前我正在使用电源按钮,这不是必需的。

请对此有所了解。我做了一些研究,但找不到任何东西。:(

4

1 回答 1

1

This is because of the Broadcast receiver limitation, I will have to use the Volume button for some actions in my application. But, this button doesn't broadcast.

我不确定这是否正确。如果您阅读Android BroadCastReceiver 的音量键上下问题,您似乎可以在 BroadCastRceiver 中检测到它。我从未尝试过,但可能值得一试。执行以下操作:

在您的 BroadcastReceiveronReceive函数中,执行以下操作:

public void onReceive(Context arg0, Intent intent) {
    if (intent!=null){
        int volume = (Integer)intent.getExtras().get("android.media.EXTRA_VOLUME_STREAM_VALUE");
        // Get the old volume from the SharedPOreferences
        // volume variable contains the current volume
        // Compare it to the old value saved. If it is greater than old value then user pressed the UP Volume button else DOWN volume.

    }
}

此外,我不确定您是否可以使其透明并仍然保持运行。不过,您可以将活动的背景设置为透明的。如何在 Android 上创建一个透明的 Activity?. 希望能帮助到你。

于 2013-07-17T04:06:25.607 回答