后台服务和前台服务有什么区别? [英] What is the difference between a background and foreground service?

查看:237
本文介绍了后台服务和前台服务有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写我的第一个Android应用程序,并且不断遇到对后台和前台服务的引用.由于我打算在我的应用程序中使用服务,所以我希望在两者之间以及它们的使用方式之间进行说明.

I am currently writing my first Android application and I keep running into references to background and foreground services. Since I intend on using a service in my application I was hoping to get a clarification between the two and how they are used.

推荐答案

也许这会回答您的问题:

Perhaps this will answer your question:

启动的服务可以使用startForeground API放置服务 在前台状态下,系统认为它是某物 用户积极地意识到,因此不是杀人的候选人 当内存不足时.默认情况下,服务是后台的,这意味着 如果系统需要杀死它们以回收更多内存(例如 在网络浏览器中显示一个大页面),就可以将其杀死 伤害很大.

A started service can use the startForeground API to put the service in a foreground state, where the system considers it to be something the user is actively aware of and thus not a candidate for killing when low on memory. By default services are background, meaning that if the system needs to kill them to reclaim more memory (such as to display a large page in a web browser), they can be killed without too much harm.

可以在此处

这篇关于后台服务和前台服务有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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