Android App Behaving Unexpectedly After Calling System.exit(0)
I'm writing a simple app with 4 activities. I'll describe it quickly so you understand what I'm trying to achieve. First activity - MainActivity has some TextEdit fields that colle
Solution 1:
Using System.exit(0) is a bad practice.
Calling exit() in this case would terminate the process, killing your other component and potentially corrupting your data. The OS could care less of course, but your users might not appreciate it.
Killing voluntarily your process will not help other applications, if they have exhausted their internal Dalvik heap limit. No matter how much physical memory a device has, the OS has a limit on how much memory Dalvik is allowed to use in any process for heap allocations. Thus, it is possible that the system has free half of its memory and a particular application still hits OOM.
Do not use System.exit(0); instead you can just use finish().
Intent intent = newIntent(this, Activity2.class);
startActivity(intent);
finish();
Post a Comment for "Android App Behaving Unexpectedly After Calling System.exit(0)"