I am working on and Android application. When my application is running and i press the recent applications button on the phone , Activity's onPause() method is called . Inside this onPause i call finish() . So the activity gets destroyed.
But its still visible in the recent applications list.
How do i make sure it is not listed in the recent applications list when i destroy my activity from onPause() .
Try doing
<activity android:name=".MainActivity"
android:excludeFromRecents="true" ...>
in your AndroidManifest.xml's activity declaration.
get more from official documentation
Whether or not the task initiated by this activity should be excluded from the list of recently used applications ("recent apps"). That is, when this activity is the root activity of a new task, this attribute determines whether the task should not appear in the list of recent apps. Set "true" if the task should be excluded from the list; set "false" if it should be included. The default value is "false".
when you want to have special properties for an Activity when starting it you supply special flags to the Intent. In this case FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS.
Go through link .
The reason may be because only your activity is destroyed not the Application instance. Android awaits may be user open up the app again. To completely terminate application you can use for above API 16 this.finishAffinity()
.
It will finish the current activity and all other under it. As doc says
Finish this activity as well as all activities immediately below it in the current task that have the same affinity
使用finishAndRemoveTask() 而不是finish() 或finishAffinity()
use
finish();
when you move to the next activity then recent activity is finish
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.