Stop Android for killing my Activity after 30 minu

2019-08-08 18:09发布

问题:

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.

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.

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

Thanks.

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.

回答1:

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