What I mean by real life context is like how would you describe when an app is paused and when it is stopped to someone who doesn't know much about the android activity lifecycle (like me :D).
From my understanding, when it is paused it's like if you were to open an app, do something then press the home button but you don't physically swipe away the app so it is still in the background. After you press the home button, the app is in a paused state right? or no?
And when it is in a stopped state, well this part I don't know. I'm not sure what it means by when the activity is "no longer visible to the user" on the android Activity Lifecycle page. Is this describing something like when you've actually ended the app, pressing the square overview button and swiping away the app?
CodePudding user response:
Paused means its no longer in the foreground but is still visible on screen. Stopped means its no longer on screen at all. But to keep a consistent pattern, you always go Running->Paused->Stopped or Running->Paused, you never skip paused.
A few examples where you may go to paused but not stopped:
- You pop up a Dialog Activity which overlays the current activity
- You hit the power button bringing up the power menu dialog.
- You perform some other UI action that overlays part of the screen.
As for your buttons presses- PAUSED and STOPPED is not a state of the app- it's a state of the Activity. An app can have multiple activities in the paused or stopped states. To be even more clear, its about the instance of an Activity- you can have two different instances of the same activity and one can be paused and one running.
Pressing the home button doesn't pause the activity, it stops it. Pressing the square button and swiping the app away does not put the Activity as Stopped, it exits the app entirely (the Activity will be paused, then stopped, then destroyed as the app exits).