简体   繁体   English

让我们完成一个android活动

[英]Let finish an android activity

I created an AlarmManager to close my main activity at a certain time. 我创建了一个AlarmManager在某个时间关闭我的主要活动。 It uses the CLEAR_TOP flag to close the main activity. 它使用CLEAR_TOP标志关闭主活动。 My problem is that if the main activity is doing something important, I must let it finish its work. 我的问题是,如果主要活动正在做重要的事情,我必须让它完成其工作。

I put the code in the onDestroy() method, but I read in the Android documentation to use instead onPause() or onSaveInstanceState (Bundle outState) . 我将代码放在onDestroy()方法中,但是我阅读了Android文档,改为使用onPause()onSaveInstanceState (Bundle outState) The problem is that I don't get how can I let my activity finish its work correctly with these methods. 问题是我不知道如何让我的活动使用这些方法正确完成其工作。

我使用了onPause()isFinishing() onPause() ,它可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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