如何prevent一个机器人活动被杀 [英] How to prevent an android activity to get killed

查看:89
本文介绍了如何prevent一个机器人活动被杀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了确实需要做不断的网络活动的应用程序。该活动网络是否连接通的AsyncTask的,有时这些工作在后台正在做(应用程序没有焦点)。我的应用程序有时会得到30分钟后死亡,即使系统似乎并不缺乏资源(内存)。

I have developed an application that does require to do constant network activity. This Activity does the network connections thru an AsyncTask, sometime this work being done in background (application not having focus). My application sometimes gets killed after 30 mins, even if the system does not seem to lack resources (memory).

我已经阅读了活动的生命周期中的应用程序基础部分的developer.android.com ,却找不到答案。什么是正确的方法以编程方式prevent我Activty被杀死。

I have read the Activity life cycle in the Application Fundamentals section on developer.android.com, but can't find an answer. What would be the proper way to programmatically prevent my Activty to get killed.

感谢你。

推荐答案

如果您使用的服务并确保它保持活跃的(先启动它,根本就没有停止它)的应用程序不会被杀死(除非它是极低的,当然内存)。

If you use a Service and make sure it stays active (by first starting it and simply not stopping it) the application wont be killed (unless it's extremely low on memory of course).

这篇关于如何prevent一个机器人活动被杀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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