Android 监听 Home 键
Android BroadcastReceiver About 764 words监听 Home 键广播
不能改reason,homekey这些字符串变量的值
private BroadcastReceiver homeListenerReceiver = new BroadcastReceiver() {
String SYSTEM_DIALOG_REASON_KEY = "reason";
String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
@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_DIALOG_REASON_KEY);
if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)) {
hide();
}
}
}
};
IntentFilter homeFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
mContext.registerReceiver(homeListenerReceiver, homeFilter);
Views: 2,529 · Posted: 2019-04-09
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...