How to clear default activity when turning off Android device?

I created an Android app. I do this by default Activity at startup.

My problem is that if I reboot heavily or the battery runs low, the device will turn off and my device will continue to start Activity , and I am stuck in the boot cycle.

How can I solve this problem?

Any help was appreciated.

+4
source share
1 answer

Well, it's simple, make BroadcastReceiver to load at boot, and a flag somewhere like ForceClosed is set to TRUE, if the application terminated without any error, set the flag to FALSE.

When you receive a bootcast, check if ForceClosed is set to TRUE, if so, do whatever you want, and then return it to FALSE.

+1
source

Source: https://habr.com/ru/post/1382219/


All Articles