Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果它在后台停留 5 分钟,我想退出我的应用程序。是否有可能以编程方式做到这一点?
可以使用计时器任务运行后台服务,该任务在指定时间段内检查应用程序的状态。这通常使用 BaseActivity 并覆盖 onStop() 和 onWindowFocusChanged() 方法来完成。在此处和此处查找更多信息