android application behaves indifferently when app is not used for a while
<p>The app works fine when called afresh and used, but it doesn't behave well when user leaves it and the application is left running in the memory. Any attempt to switch back to it when it is running causes crash or black frozen screen. It might happen only when some time is left since it was opened first. 
To solve this, I am thinking of placing a Quit button and used this to kill the app</p>

<pre><code>case MENU_QUIT: int pid = android.os.Process.myPid();
        System.out.println("Process id:"+pid);
        android.os.Process.killProcess(pid); 
        return true;
</code></pre>

<p>But I believe this is not the right way to solve the problem. Could somebody suggest a better idea.</p>
