[英]Prevent an android activity to go pause state when HOME button is pressed
While using an editor activity I will prevent a HOME button press.在使用编辑器活动时,我会阻止按下 HOME 按钮。 But... I have tried Key events catching up on activity nothing hits there.
但是......我已经尝试过关键事件来追赶活动,那里没有任何影响。 also tried onUserLeaveHint() to show a confirmation dialog.
还尝试了 onUserLeaveHint() 以显示确认对话框。
I started activity like following我开始了以下活动
final Intent intent = new Intent(activity, A.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivityForResult(intent, "EDITOR");
any idea what could be a good practice to achieve this?知道什么是实现这一目标的好习惯吗?
I don't think its possible to do, you cannot override Home button press and hence you cannot prevent your activity to go to in pause state.我认为这是不可能的,你不能覆盖主页按钮的按下,因此你不能阻止你的活动到 go 到暂停 state。 actually it goes to stop state when you click on home.
实际上,当您单击主页时,它会停止 state。 first pause and then stop.
先暂停,然后停止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.