bob
bob

Reputation: 155

App crash after long time is in background

hi app crashes when it is in background .so what is good way to handle

i am doing

  @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        if (savedInstanceState == null) {
            finish();
        }
    }

is this good ?as onRestoreInstanceState will call only after system restart my app right ?

Upvotes: 2

Views: 4763

Answers (2)

Bar Sagiv
Bar Sagiv

Reputation: 23

It is very simple bro: You have two options: 1) Use UnCaught exception handler inside your code so when crush happened you could save the reason for that crush. OR 2) Just put your app into background until it crush and than use command line with adb: insert that line - "adb logcat > newTextFileName.txt" Than go to that file and search for the word "FATAL" in the end of the file There you can see the class and the line number that caused your problem.

Upvotes: 0

Paul Lammertsma
Paul Lammertsma

Reputation: 38252

No, this is an atrocious approach. You should investigate the cause of your crash and correctly handle restoring the state of your application.

The best way to debug this is to enable the developer setting on your phone, under "Developer settings", called "Don't keep activities". This will help you investigate the cause of your crashes by reproducing the behavior of Android restarting your activities from a saved instance state.

Upvotes: 11

Related Questions