Saving Application State in Android
I am writing an app where I get all the data from the rest cal开发者_JAVA技巧l and display all the data in a custom component list(based on Linear Layout) which is added to a LinearLayout
. I write this code in onCreate
of the activity.
The problem is when I switch activity using startActivity
, and come back to the calling activity (using startActivity
) then onCreate
is called again. I see onPause
, onStop
called when I call other activity.
Is there any way that I can save the application's state?
Check this question: "How do I save an android application state".
Edit:
You can also avoid some calls to onCreate()
by adding a
android:launchMode="singleTask"
to your Activity
in the AndroidManifest
.
精彩评论