Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Catch when Android application went on background

Tags:

android

I need help with Android. Here is problem I need to catch event when application went to background. (ex. home is pressed or any other action that push my app in backgound) Currently I'm able to catch onPause for activity

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
}

Is there any override for some event on application level ?

like image 262
manuel Avatar asked Mar 01 '11 14:03

manuel


1 Answers

From your comment it sounds like you want to know when your program returns from the background, instead of when it goes to the background.

You can use onResume for that. also, see the Activity Lifecycle. You can see the remark "activity comes to the foreground", which is what I gather from your comment the thing you want.

Note: your activity will call onResume the first time the activity is started, so you might want to set a boolean in onPause to signal your app that it actually went to the background.

like image 83
Nanne Avatar answered Sep 28 '22 00:09

Nanne