我用BroadcastReceiver
写了一个ACTION_CLOSE_SYSTEM_DIALOGS
来捕获home button press event
:
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
{
String reason = intent.getStringExtra(SYSTEM_REASON);
if (reason != null)
{
if (reason.equals(SYSTEM_HOME_KEY))
{
//home key pressed
} else if (reason.equals(SYSTEM_RECENT_APPS))
{
// long pressed home key
}
}
}
}
此代码仅在屏幕未锁定时有效。知道为什么这不适用于锁定屏幕?如何重新获得它?