Question: 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 ?

Answer: 
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.
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.