如何保持活动在后台运行? [英] How to keep activity running in background?
问题描述
你们大多数人必须使用过"whatsapp"和"viber".这些应用程序即使退出也始终保持运行状态.我希望我的一项活动在首次运行后能够在后台继续运行.而且我还希望整个应用程序像viber和whatsapp一样在后台继续运行.我该怎么办?
Most of you must have used "whatsapp" and "viber". These apps constantly keep running even when they are exited. I want one of my activities to keep running in the background after its being ran for the first time. And I also want the whole app to keep running in the background like viber and whatsapp do. How can I do that?
推荐答案
使用service
.阅读此和
Use service
. Read this and this about details of service.
您可以使活动在后台运行.但是我认为让服务在后台运行绝对是一个更好的主意.通过阅读上面的两个链接,您将对服务有一个基本的了解.
You can keep your activity running in the background. But I think it is definitely a better idea to keep a service running in the background. You will get a basic idea about the service by reading above two links.
这篇关于如何保持活动在后台运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!