markus.tullius
Dauergast
- 342
Das macht kein Sinn. Der ActivityManager ist dafür uninteressant. Es kann nur eine Klasse dies verwalten, die nebenläufig ist. Die richtige Klasse ist der ActivityThread. Dort wird alles geregelt.
Denn Zusammenhang sind man schon, wenn man sich die Stacktrace von Exception anschaut.
Und in der Doku steht explizit:
To save persistent data, such as user preferences or data for a database, you should take appropriate opportunities when your activity is in the foreground. If no such opportunity arises, you should save such data during the onStop() method.
es steht dort auch:
Because the onCreate() method is called whether the system is creating a new instance of your activity or recreating a previous one, you must check whether the state Bundle is null before you attempt to read it. If it is null, then the system is creating a new instance of the activity, instead of restoring a previous one that was destroyed.
The Activity Lifecycle | Android Developers
Wenn in der App die Methode finish() aufrufen wird, wird die Methode onDestroy() aufgerufen, und das Bundle ist weg. Es ist sogar weniger persistent als mein Vorschlag.
Denn Zusammenhang sind man schon, wenn man sich die Stacktrace von Exception anschaut.
Code:
E/AndroidRuntime(760): at android.app.ActivityThread.main(ActivityThread.java:5039)
E/AndroidRuntime(760): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(760): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(760): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime(760): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
Und in der Doku steht explizit:
To save persistent data, such as user preferences or data for a database, you should take appropriate opportunities when your activity is in the foreground. If no such opportunity arises, you should save such data during the onStop() method.
es steht dort auch:
Because the onCreate() method is called whether the system is creating a new instance of your activity or recreating a previous one, you must check whether the state Bundle is null before you attempt to read it. If it is null, then the system is creating a new instance of the activity, instead of restoring a previous one that was destroyed.
The Activity Lifecycle | Android Developers
Wenn in der App die Methode finish() aufrufen wird, wird die Methode onDestroy() aufgerufen, und das Bundle ist weg. Es ist sogar weniger persistent als mein Vorschlag.