Skip to main content
Commonmark migration
Source Link

In Android, there are Activities. When your app starts, some Activity is launched. You can get its state from few methods. In your case:

onCreate() - activity is just created

 

onPause() - another activity comes foreground

 

onResume() - user returns to activity

You can check Activity lifecycle in this image: http://1.bp.blogspot.com/-OqYcaNPtxmA/Ty09w4B2yiI/AAAAAAAAAQE/cnMwJxhklQU/s1600/activity_lifecycle.png

Note that android apps can have more than one activity. So for example onPause() doesn't always mean app went to background, since another activity could be launched and the first one is paused.

Docs:
https://developer.android.com/reference/android/app/Activity.html

https://developer.android.com/training/basics/activity-lifecycle/index.html

In Android, there are Activities. When your app starts, some Activity is launched. You can get its state from few methods. In your case:

onCreate() - activity is just created

 

onPause() - another activity comes foreground

 

onResume() - user returns to activity

You can check Activity lifecycle in this image: http://1.bp.blogspot.com/-OqYcaNPtxmA/Ty09w4B2yiI/AAAAAAAAAQE/cnMwJxhklQU/s1600/activity_lifecycle.png

Note that android apps can have more than one activity. So for example onPause() doesn't always mean app went to background, since another activity could be launched and the first one is paused.

Docs:
https://developer.android.com/reference/android/app/Activity.html

https://developer.android.com/training/basics/activity-lifecycle/index.html

In Android, there are Activities. When your app starts, some Activity is launched. You can get its state from few methods. In your case:

onCreate() - activity is just created

onPause() - another activity comes foreground

onResume() - user returns to activity

You can check Activity lifecycle in this image: http://1.bp.blogspot.com/-OqYcaNPtxmA/Ty09w4B2yiI/AAAAAAAAAQE/cnMwJxhklQU/s1600/activity_lifecycle.png

Note that android apps can have more than one activity. So for example onPause() doesn't always mean app went to background, since another activity could be launched and the first one is paused.

Docs:
https://developer.android.com/reference/android/app/Activity.html

https://developer.android.com/training/basics/activity-lifecycle/index.html

Source Link
johnyX
  • 143
  • 1
  • 2
  • 12

In Android, there are Activities. When your app starts, some Activity is launched. You can get its state from few methods. In your case:

onCreate() - activity is just created

onPause() - another activity comes foreground

onResume() - user returns to activity

You can check Activity lifecycle in this image: http://1.bp.blogspot.com/-OqYcaNPtxmA/Ty09w4B2yiI/AAAAAAAAAQE/cnMwJxhklQU/s1600/activity_lifecycle.png

Note that android apps can have more than one activity. So for example onPause() doesn't always mean app went to background, since another activity could be launched and the first one is paused.

Docs:
https://developer.android.com/reference/android/app/Activity.html

https://developer.android.com/training/basics/activity-lifecycle/index.html