-3

I want to do some specific piece of code on settings->applications->manage applications->app name->force stop button.How can I get this force stop button event?is it possible to get this event?

Nitish Patel
  • 1,026
  • 2
  • 19
  • 36

1 Answers1

2

You can't do that because that dialog is shown by Android OS and you have no control over that part. What you need to do is simply make sure your Android code is clean and correct, so you will get rid of such errors. Another thing you can do (but I strongly recommend to not let loose your app in the wild with this) is to set a DefaultUncaughtExceptionHandler. Ex:

Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
    public void uncaughtException(Thread thread, Throwable ex) {
        // log, or create some statistics ... whatever
    }
});

But from experience, the behavior of the app once that thread is dead (especially the UI thread) might be unexpected, so maybe it's preferable to have your app dead. But again: you must fix the cases when the app crashes.

gunar
  • 14,660
  • 7
  • 56
  • 87