Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear default activity on shutdown of android device?

I have created an Android application. I make it my default Activity on starting it.

My problem is that if I hard reboot or if the battery goes down, the device shuts down and my device keeps on starting that Activity and I am stuck into a boot loop.

How can I solve this problem?

Any help appreciated.

like image 744
Sandeep Avatar asked Nov 14 '22 14:11

Sandeep


1 Answers

Well the solution is simple , make a BroadcastReceiver for a on Boot up , and a flag somewhere like ForceClosed set to TRUE, if application terminated without any error then set the flag to FALSE .

On receiving the Boot Broadcast , check if ForceClosed is TRUE , if yes , do watever you want , and then set it back to FALSE .

like image 75
Tapan Thaker Avatar answered Nov 16 '22 02:11

Tapan Thaker