The Power of Android Stop Application Callback?

If the application is forced to stop by following the steps Settings-> Application-> ManageApplications → -> Force Stop, does the android call onDestroy for Activity or Application? (If not, is there a way to find out if the application died due to a power stop caused by the user).

+3
source share
3 answers

Process.killProcess(int pid) application to terminate will kill the entire process (i.e. Process.killProcess(int pid) ). All resources associated with the application will be deleted and freed by the kernel. So, no, you cannot intercept this action.

When you release your application on the market, the developer's console will provide you with statistics regarding power closures, failures, etc. (if that's what you are asking about).

+8
source

In short, no, onDestroy() not called, and you cannot do this. Android does not support it.

More extended answer ...

onDestroy() does not seem to be called in this script. I tested this by trying to use its Toast for me before calling super.onDestroy, but the Toast message never appeared. (And according to this post , onDestroy() really unreliable and will not be called often, if at all, on phones, whereas it can be called on the emulator - so keep that in mind). Instead, killProcess() is called, and we cannot intercept it.

In addition, in accordance with the accepted answer in this message , it seems that we cannot even catch and perform tasks after stopping the forced stop of the user.

+3
source

Not. It's impossible. I did not consider this Android code, but I would suggest that "force stop" just calls kill the process id of your application. So the only way you could intercept this is to capture signals that I don't think Android allows.

If you were rooted, you could do this, but not in any standard way.

0
source

All Articles