创建 wifi 扫描作为 android 服务
目前正在编写一个wifi定位程序,我需要扫描周围的活动AP,以便计算用户的当前位置。但是,用户可以设置应用程序启动 WiFi 扫描的时间(0-10 秒)(例如 5 秒,程序将每 5 秒启动一次 WiFi 扫描)。从[此处](http://developer.android.com/reference/android/app/Service.html#WhatIsAService)中所述,它说“应用程序组件代表应用程序执行长时间运行的操作的愿望同时不与用户交互或提供功能供其他应用程序使用。”。那么想知道在这种情况下是否最好在我的程序中创建一个服务然后运行一个 TimerTask ?
Currently writing a wifi positioning program and i need to scan the surrounding for active APs so as to calculate the current position of the user. However, user can set the time (0-10 secs) at which the app initiate WiFi scanning (for example, 5 sec, the program would initiate WiFi scanning every 5 secs). And from what is stated in [here] (http://developer.android.com/reference/android/app/Service.html#WhatIsAService) and it says "application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use.". So was wondering whether it is best to create a Service in my program then running a TimerTask in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,我将使用 Service 和 TimerTask,如此处
In this case, i would use Service and TimerTask like here