You're on an activity and you press the home button.
Then you long press home menu button, and select the activity you were on, from the 'recent activities' screen.
What method is called when the activity shows again? onResume
, onRestart
or any other?
I believe onResume
will be called anyways even after pause
or stopped
.
onRestart
may be called if activity has been stopped
in the background
The recommendation is to save your data in onPause
and rebuild it on onResume
with some flags, so flags can tell you if onResume
called after onPause
/ onStopped
or Activity is freshly created.
Taken from the Android developer website
"... When the user leaves your activity, the system calls onStop() to stop the activity (1). If the user returns while the activity is stopped, the system calls onRestart() (2), quickly followed by onStart() (3) and onResume() (4). Notice that no matter what scenario causes the activity to stop, the system always calls onPause() before calling onStop()... "
Here is the Activity
So no Matter what onResume()
would get eventually called.
You can download the ActivityDemo which exhibits the Android lifecycle accurately. This should help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.