Android app start and end event

后端 未结 5 952

I have an app which track user activity on app which include time etc, Now if user has opened the app, It will start an session and till user in this app , his session will cont

5条回答
  •  被撕碎了的回忆
    2021-02-05 22:23

    Extend all your Activities from BaseActivity like below. This is the best option for you as onPause and onResume methods are guaranteed to be called whenever your Activities show up or go away from phone screen.

    class BaseActivity extends Activity {
    
    
        @Override
        protected void onResume() {
            super.onResume();
            // Start Logging
        }
    
        @Override
        protected void onPause() {
            super.onPause();
            // End Logging
        }
    }
    

提交回复
热议问题