Android app crash after clearing memory

My app looks good. but when I try to clear the memory that is native to my Galaxy S4, when I open the application again, it seems that all the glitches and crashes give NullPointerException. The same thing happens when an application remains open for a long period of time.

enter image description here

Is there a way to permanently close my application when such things happen?

I'm close with

db.close();
finish();

just need to know when

+3
source share
2 answers

, - , , "", , finish(). , ​​ , , .

Bundle instance state to save information View (, , EditText). , , - , . , , such as member variables that track the user progress in the activity.

onSaveInstanceState (Bundle outState) onRestoreInstanceState (Bundle savedInstanceState)

enter image description here

http://developer.android.com/training/basics/activity-lifecycle/recreating.html

+3

, , :

EXIT .

Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("LOGOUT", true);
startActivity(intent);

onCreate() MainActivity.class ,

if (getIntent().getBooleanExtra("LOGOUT", false))
{
    finish();
}
+1

All Articles