GPS定位服务上 - Android版 [英] GPS Location on Service - Android

查看:141
本文介绍了GPS定位服务上 - Android版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/13810662/requestlocationupdates-throws-exception\">requestLocationUpdates抛出异常

我试图创建一种服务,当服务器问我,送我的位置。但找不到做到这一点,因为一切是一个后台服务。我也不需要有UI界面。当我打电话requestUpdate()抛出了我一个错误,停止应用程序

I'm trying to create a service that when the server ask me, send my location. but can not find the way to do it, since everything is a background service. and I do not need to have UI interface. when I call requestUpdate () throws me an error and stops the application

locManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER, 15000, 0, locationListener);

runE​​xception内螺纹无法创建处理程序,也没有所谓的活套。prepare()

我怎么可以运行一些更新从我服务的位置?
任何人有任何例子或东西来帮助我?我没有太多经验呢。

How I can run something to update the position from my service? anyone have any example or something to help me? I have not much experience yet.

推荐答案

在你的异常好,其著名的问题,请参见响应:

Well, its famous problem, See response in your Exception:

 ... that has not called Looper.prepare()

您需要提供应用程序的主尺蠖。

You need provide application's main looper.

下面是有效的实现:

mLocationManager.requestLocationUpdates(
                                        LocationManager.GPS_PROVIDER,
                                        15000,
                                        0,
                                        locationListener,
                                        Looper.getMainLooper()
                                        );

这篇关于GPS定位服务上 - Android版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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