离背景30分钟后停止Android杀死我的活动 [英] Stop Android for killing my Activity after 30 minutes from background

查看:94
本文介绍了离背景30分钟后停止Android杀死我的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,其中有一个活动,其中包含一个计时器,无论用户何时进入该屏幕,计时器都会运行.如果用户在不停止计时器的情况下通过按下主页按钮离开了该屏幕,则该通知将通知该用户,然后,如果该用户以任何方式再次回到该应用程序,则应显示相同的屏幕.

I am creating an application where there is an activity which contains a timer running when ever user comes to that screen. If user leaves that screen by pressing home button without stopping the timer then the user is notified by the notification and then if the user again come back to the app from any means then the same screen should appear.

如果用户在30分钟之前返回屏幕,则可以正常工作.因为30分钟后,android从后台终止了我的活动,并且我的应用程序从头开始启动.

It is working fine if the user comes back to the screen before 30 minutes. Because after 30 minutes android kills my activity from background and my application starts from beginning.

我想阻止android从后台杀死我的活动.如果有人有任何想法请帮忙...

I want to stop android for killing my activity from background. Please help if any body has any idea...

谢谢.

如何将活动链接到服务?这样一来,当Android OS试图破坏我的活动时,它就不会这样做,因为我的活动与正在运行的服务有关.

How can i link an Activity to a service? So that when Android OS tries to destroy my activity then it won't let it do because my activity is linked with the running service.

推荐答案

使用服务来进行后台工作.在这种情况下,Activity应该类似于链接到Service的简单UI外观.

Use Services to doing background work. In this case Activity should be like a simple UI facade linked to Service.

这篇关于离背景30分钟后停止Android杀死我的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆