Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
283 views
in Technique[技术] by (71.8m points)

android - Handle force close?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:
https://android.googlesource.com/platform/packages/apps/Settings/+/froyo-release/src/com/android/settings/ManageApplications.java

InstalledAppDetails:
https://android.googlesource.com/platform/packages/apps/Settings/+/froyo-release/src/com/android/settings/InstalledAppDetails.java

ActivityManager.forceStopPackage:
https://android.googlesource.com/platform/frameworks/base/+/froyo-release/core/java/android/app/ActivityManager.java

ActivityManagerNative.forceStopPackage:
https://android.googlesource.com/platform/frameworks/base/+/froyo-release/core/java/android/app/ActivityManagerNative.java

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...