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.
Home
How can i do this?
How to remove activity from recent applications?
I think android:excludeFromRecents="true" should do the trick. Use it in your manifest
android:excludeFromRecents="true"
What I want to do is that the dialog should not be displayed.
dialog.cancel() in onPause()
dialog.cancel()
onPause()
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.
Use yourdialog.cancel() inside your onPause() activity. See http://developer.android.com/reference/android/app/Activity.html . Example:
yourdialog.cancel()
@Override protected void onPause() { super.onPause(); if (yourdialog != null) { yourdialog.cancel(); } }
You can override onStop() activity of your dialog:
onStop()
@Override protected void onStop() { super.onStop(); finish(); }
However, this also means that your dialog will close when the device is locked.