简体   繁体   English

禁用如何破坏我的活动

[英]How disable destroy my activity

My app contains Activity. 我的应用包含“活动”。 I start it by Intent. 我从Intent开始。 Than I turn my Activity to background (switch to Home Screen or similar). 比起将我的活动设置为背景(切换到主屏幕或类似功能)。 After some time the OS destroy my Activity (I think when memory is low). 一段时间后,操作系统破坏了我的活动(我认为内存不足时)。 It is possible protect my Activity (in background) from destroy by OS? 是否可以保护我的活动(在后台)免受操作系统破坏? Or increase it priority to maximum? 还是将其优先级提高到最大?

Activity is made for a UI holding elements. 为UI保持元素进行活动。 Service is made for background tasks. 为后台任务提供服务。 From this already sounds logic to make a Service instead of try to keep Activity in background. 由此看来,建立服务而不是尝试将Activity置于后台是合理的逻辑。

Also there are BroadcastReceivers, which will be called on different actions. 另外,还有BroadcastReceivers,它们将在不同的动作上被调用。 Boot completed, Internet lost, got and so on. 引导完成,互联网丢失,丢失等等。

I think you know what do you want to archive, I would suggest telling in detail an will get a lot better response, with enumeration, maybe code part of component needed to use. 我认为您知道要存档的内容,建议您详细列举一个枚举,可能会得到更好的响应,枚举可能是需要使用的组件代码部分。

Keeping Activity forced alive is a bad idea in general. 通常,让Activity处于活动状态是一个坏主意。

您可以在后台加载WebView。

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

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