本文主要是介绍Android Best Practices 主要内容,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
本文用途:搜索、跟踪阅读进度、概括官方文档内容。
忽略介绍、原理、优缺点等内容。
Running in a Background Service
最有用: IntentService
流程:创建IntentService, 发送请求, 接收结果
Creating a Background Service 原文链接
1. 继承 IntentService
2.override onHandleIntent(Intent workIntent), 不用override其他callbacks 。执行任务的代码就在onHandleIntent()中。
3、添加<service>至<application>
IntentService内部有一个线程、IntentService可以相应多个请求(有队列,逐个完成)、执行完后自动停止。
Sending Work Requests to the Background Service 原文链接
1、创建explicit intent 2、startService()
这篇关于Android Best Practices 主要内容的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!