0

In my App I have several activities which are obviously related to each other. Whenever I am on some activity and the user kills my app by using any task killer. I want to do two things

  1. Clear the Notification which I added when the user logged in..
  2. finish all the activities other than the first Activity i.e. Login Activity

Now if user starts again my app either from the recent tasks or from launcher I want to start from the first activity i.e. Login Activity...

Presently my code works absolutely fine if I use android manage process and end the activity or force close the app from android task manager. But if I am using some other task killer app i.e. Advanced task killer, after closing the app when I relaunch the App from recent apps the it tries to restart from the last used Activity instead of Login Activty and gives an ugly force close error... The Notification is also not cleared when in this case.

How do I handle third party task killers ?

I have read several threads on SO but couldn't get the pointers, few of them are ...

related to task killer

related to Notification

Community
  • 1
  • 1
Amit
  • 13,134
  • 17
  • 77
  • 148

1 Answers1

0

first off all make your application to run as service not as activity. and bind your service as STICKY so that after killing your app it will start again instantly and only your application can stop your own service. for more information refer http://developer.android.com/guide/components/bound-services.html

Rahul
  • 710
  • 1
  • 8
  • 25
  • I have not used service in my app so far... Do I need to use that just for it ? – Amit Dec 27 '12 at 06:20
  • yes offcourse ....because activity can be killed by any other application but your service cannot be stoped. :) so make it as service and then nobody can stop your service other than you :) – Rahul Dec 27 '12 at 06:23