Check whether activity is active

前端 未结 8 2083
眼角桃花
眼角桃花 2020-11-27 04:47

I\'m having a problem with a listener in a certain activity.

The problem is that this listener contains an alert.show(); which can be called after we try to push a

相关标签:
8条回答
  • 2020-11-27 05:28

    If you do not want to show alert dialog or other operation after you close your activity then use this code. it works 100% accurately.

    if(!(DownloadVideoActivity.this.isDestroyed()))
    {
       //show alert dialog or other things
    }
    
    0 讨论(0)
  • 2020-11-27 05:29

    There might be an easier way I can't think of but one way is to implement it yourself. On onResume() you set a member variable mIsRunning to true and on onPause() back to false. Using this boolean you should know not to call alert.show() on your callback.

    0 讨论(0)
提交回复
热议问题