Android - How to remove activity from recent apps?

I created a user dialog in an Android application. This dialogue is an action with a dialogue theme. Now suppose the application displays this dialog box, the user clicked "Home" to return to Android Home mode. Later, press and hold the Home button, then select my application from the latest applications. It will display the dialog again. What I want to do here is that the dialog should not be displayed. I want to show the activity that caused this dialogue.

How can i do this?

+8
android
source share
4 answers

How to remove activity from recent applications?

I think android:excludeFromRecents="true" should do the trick. Use it in your manifest


What I want to do is that the dialog should not be displayed.

dialog.cancel() in onPause()

+26
source share

You can also use the Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS flag:

 ..... i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivity(i); 

The launch you start will not be in recent applications.

+3
source share

Use yourdialog.cancel() inside your onPause() activity. See http://developer.android.com/reference/android/app/Activity.html . Example:

 @Override protected void onPause() { super.onPause(); if (yourdialog != null) { yourdialog.cancel(); } } 
+2
source share

You can override onStop() activity of your dialog:

 @Override protected void onStop() { super.onStop(); finish(); } 

However, this also means that your dialog will close when the device is locked.

0
source share

All Articles