Hello,
Is there a way to notify an activity/service of a force-close request right before it gets killed?
I mean when the user hits the force close button in Menu>Settings>Applications>Manage applications>app name>Force Close.
Thanks!
Hello,
Is there a way to notify an activity/service of a force-close request right before it gets killed?
I mean when the user hits the force close button in Menu>Settings>Applications>Manage applications>app name>Force Close.
Thanks!
I'm pretty new here and to Android programming in general, so forgive me if this isn't strictly correct. However, my understanding is that the Application Not Responding (ANR) dialog is only displayed if your application is either a) non-responsive or b) has thrown an exception that was not caught.
In case a) the application will not be able to respond to any force-close notification in a reasonable amount of time since it's already hung up enough to generate the ANR. In case b) your application is already dead.
I think the ActivityManager just kills the hosting process, so you may not be able to get any event/message/warning. To check you could create an app that has a single Activity that lets you know if onDestroy is called, and further if isFinishing is invoked.
The path to "Menu>Settings>Applications>Manage applications>app name>Force Close" in the source, in case it helps, is:
ManageApplications: http://android.git.kernel.org/?p=platform/packages/apps/Settings.git;a=blob_plain;f=src/com/android/settings/ManageApplications.java;hb=master
InstalledAppDetails: http://android.git.kernel.org/?p=platform/packages/apps/Settings.git;a=blob_plain;f=src/com/android/settings/InstalledAppDetails.java;hb=master
ActivityManager.forceStopPackage: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob_plain;f=core/java/android/app/ActivityManager.java;hb=HEAD
ActivityManagerNative.forceStopPackage: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob_plain;f=core/java/android/app/ActivityManagerNative.java;hb=HEAD
Once it gets the native level it hands off to a Service that does the dirty work. Again, I would guess it just stops the process, but that's a guess, and I don't know off the top of my head where the other side of the native interface is in the source to check (though it's there somewhere if you poke around and want to know for sure).
Also you might want to add why you want this information to your question, there might be a different/better angle to getting what you want accomplished, depending on that.