2

I have the requirement to close the activity as soon as it get launched,to achieve this i used finish() method, but it still exists in running application list.

Please suggest me some solution..

SweetWisher ツ
  • 7,296
  • 2
  • 30
  • 74
  • 2
    what you're saying doesn't make sense. After you finish an activity, it shouldn't exist in memory unless you are leaking it – Leo Oct 27 '14 at 05:38
  • The activity you're calling the finish() method from is destroyed and all its resources are queued for garbage collection, because a reference to this activity becomes inaccessible. So, all memory that was used by this activity will be freed during next GC cycle. – SweetWisher ツ Oct 27 '14 at 05:39
  • and the app won't be finished only the activity is get closed. Android keeps processes around in case the user wants to restart the app, this makes the startup phase faster. The process will not be doing anything and if memory needs to be reclaimed, the process will be killed. Don't worry about it :) – SweetWisher ツ Oct 27 '14 at 05:51
  • After launching an activity, the activity is getting closed, but still its there in list of running application? I want to remove it from Running application list.. – Shakeera Khadari Oct 27 '14 at 05:56
  • Do you mean by **Recent apps** ? then please have a [look here](http://stackoverflow.com/a/13385366/2591002) – SweetWisher ツ Oct 27 '14 at 05:58
  • Thanks for Reply..This is my requirement, is there any way to achieve this?? – Shakeera Khadari Oct 27 '14 at 06:03

1 Answers1

4

The activity you're calling the finish() method, is destroyed and all its resources are queued for garbage collection, because a reference to this activity becomes inaccessible. So, all memory that was used by this activity will be freed during next GC cycle. and by findihing teh activity, you are destroying the actviity not the app..

Please keep in mind :

Android keeps processes around in case the user wants to restart the app, this makes the startup phase faster. The process will not be doing anything and if memory needs to be reclaimed, the process will be killed. Don't worry about it :)

To remove your app from Recent app list : just specify android:excludeFromRecents="true" in the manifest

Refer this link for better explanation

Community
  • 1
  • 1
SweetWisher ツ
  • 7,296
  • 2
  • 30
  • 74