简体   繁体   English

当按下 HOME 按钮时,防止 android 活动到 go 暂停 state

[英]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.

相关问题 当按下主页按钮时,将活动状态保存在android中 - Save activity state in android when home button pressed 按下主页或后退按钮时如何暂停/停止音乐? - How to pause/stop music when home or back button is pressed? 按下后退按钮后,按原样恢复原始活动(如主页按钮) - Restoring original activity as it is (like home button) when back button pressed 我想在按下按钮时进行其他活动 - I want to go other activity when the button is pressed Android如何防止后退按钮退出应用程序(按下主页按钮后) - Android How to prevent back button from quitting application (after home button pressed) Android:当我单击时按钮不会更改为暂停状态 - Android: button is not changing to pause state when i click 手机接听来电时暂停音乐,按下主屏幕按钮并且手机屏幕关闭(锁定屏幕) - Pause music when phone receives any incoming calls, home button is pressed and when phone screen goes off(lockscreen) 按下按钮时的随机活动 - Random activity when button pressed 按下“主页”按钮后,从点击图标应用程序再次启动我的活动后,我的活动不会重新加载 - After Home button pressed, my Activity not reload when launch it again from click icon app Android:防止在 ImageView 上没有图像时转到下一个活动 - Android: Prevent go to next activity when there's no image at ImageView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM