简体   繁体   中英

Android manifest file: always start application from the beaning when user resuming the application after pressing the home button

我的应用程序包含一些默认意图和用户定义的内容,我希望用户在按下主屏幕按钮后恢复应用程序时,我的应用程序始终从bean启动

Whenever the 'Home' button is pressed, the application is paused. and onPause() is called.

Whenever it is resumes, onResume() method is called.

override the onResume() method, as you override onCreate(), and do all the things necessary to be done when application resumes, inside the onResume() method.

Sudeep , Supporting Sheikh Alam I would like to add below code to your activity to track whether your activity is focussed

  @Override
    public void onWindowFocusChanged (boolean hasFocus)
    {
        super.onWindowFocusChanged (hasFocus);      
        if(hasFocus){
            //your code here when app has focus
        }       
    }

Hope it helps!Good Luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM