学习来源:《网易云课堂-Android4.0应用开发第一季》
Service作为Android的四大组件之一,常见的功能如闹钟、音乐播放、网络加载图片等都是Service实现的。
今天总结一下我之前写得通过Service给服务器实时发送GPS信息。
首先,需要提出的是,在Android开发官网中,有关于以下的说明:
Most confusion about the Service class actually revolves around what it is not:
- A Service is not a separate process. The Service object itself does not imply it is running in its own process; unless otherwise specified, it runs in the same process as the application it is part of.
- A Service is

本文介绍了Android开发中Service组件的应用,强调Service并非独立进程或线程,而是用于在后台持续运行任务。以实时发送GPS信息到服务器为例,详细讲述了Service的生命周期和如何创建线程处理耗时操作。示例代码展示了GPSLocationListener的实现,实现了将GPS数据发送到Servlet服务器。后续计划在服务器端进一步开发,以显示地图并实时展示位置。
最低0.47元/天 解锁文章
740

被折叠的 条评论
为什么被折叠?



