Can you track when an android application has been terminated?

前端 未结 3 611
予麋鹿
予麋鹿 2020-12-06 17:54

Looked at android documentation and it appears that we don\'t have the ability to know when an app shuts down. Whether it was explicitly by the user or automatically by the

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-06 17:59

    Make a BaseActivity extending Activity in your Application and extends this BaseActivity instead of Activity. In this BaseActivity override the onDestroy() method. Like

     @Override
     protected void onDestroy() {
          super.onDestroy();
         //Write the code that you want to do if the application terminates
     }
    

提交回复
热议问题