简体   繁体   中英

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. But... I have tried Key events catching up on activity nothing hits there. also tried onUserLeaveHint() to show a confirmation dialog.

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. actually it goes to stop state when you click on home. first pause and then stop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM