Skip to content Skip to sidebar Skip to footer

How To Know Our App Has Gone To Background In Android

When user goes to other apps from my app or presses device home button from my app or etc , then my app will be sent to background. And in the background am doing some stuff . So h

Solution 1:

Using onPause isn't tedious, and may be your only solution anyway. Create an abstract Activity class that all your Activity classes extend and do whatever you need to do in onPause there:

public abstract class BaseActivity extends Activity {

    @Override
    public void onPause() {

        super.onPause();
        // Do whatever you need to do in onPause here
    }
}

Using this example, all your Activity classes should now extend BaseActivity.


Post a Comment for "How To Know Our App Has Gone To Background In Android"