local service 和remote service 区别?适用场合?

本文讨论了在Android应用中使用服务来进行长时间运行的操作的重要性。服务进程的优先级高于背景线程,确保即使在触发活动不再存在时,关键任务也能继续执行。文章通过播放背景音乐和上传图片到网站的例子说明了这一点,并强调了广播接收器也应该使用服务来处理耗时的任务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Because a process running a service is ranked higher than one with background activities, an activity that initiates a long-running operation might do well to start a service for that operation, rather than simply spawn a thread — particularly if the operation will likely outlast the activity. Examples of this are playing music in the background and uploading a picture taken by the camera to a web site. Using a service guarantees that the operation will have at least "service process" priority, regardless of what happens to the activity. As noted in the Broadcast receiver lifecycle section earlier, this is the same reason that broadcast receivers should employ services rather than simply put time-consuming operations in a thread.
只有service 的进程比只有分线程的process 优先级 高  持续时间有可能更长。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值