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:
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