手动添加位置更新停止在Eclipse工作 [英] Manually added location updates stop working in Eclipse

查看:99
本文介绍了手动添加位置更新停止在Eclipse工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个1.5的Andr​​oid应用程序。在Windows XP上开发在Eclipse 3.4.2。我有一个图形页面,都要求更新等。

I'm working on a 1.5 Android application. Developing in Eclipse 3.4.2 on Windows XP. I have a MapView, have requested updates, etc.

的问题是,经过第一手动注入的GPS坐标,该应用停止认识到了GPS坐标已发送。

The problem is that after the first manually injected GPS coordinate, the app stops recognizing that a GPS coord has been sent.

LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);  
MapController mc = mapView.getController();

TextView locationText = (TextView) findViewById(R.id.LocationBar);

LocationListener locationListener = new MyLocationListener(mc, itemizedOverlay, locationText);

lm.requestLocationUpdates(
    LocationManager.GPS_PROVIDER, 
    0, 
    0, 
    locationListener);

然后MyLocationListener只需在一个TextView以匹配新的GPS坐标的变化值。

Then MyLocationListener simply changes the value in a TextView to match the new GPS coordinate.

public void onLocationChanged(Location loc) {
		if (loc == null) {
			return;
		}
		double lat = loc.getLatitude();
        double lng = loc.getLongitude();

        GeoPoint p = new GeoPoint(
            (int) (lat * 1E6), 
            (int) (lng * 1E6));

        mc.animateTo(p);

        itemizedOverlay.addOverlay(new OverlayItem(p, "title", "snippet"));

        String location = String.format("%f lat %f long", lat, lng);

        locationText.setText(location);

	}

我添加了一些记录在onLocationChanged方法,它永远只能看到一个位置的第一的时候,我尝试发送更新。所有后续的不火的onLocationChanged方法。

I added some logging in the onLocationChanged method and it only ever sees a Location the first time that I attempt to send an update. All subsequent ones don't fire the onLocationChanged method.

附加信息:

在logcat的输出如下:

The logcat output is as follows:

10-02 17:22:34.423: INFO/gps(6671): Provider gps is has status changed to 1. Extras: Bundle[mParcelledData.dataSize=52]

首先GPS更新是伪造的:

First GPS update is faked:

10-02 17:22:49.383: INFO/gps(6671): Location provided by location provider: Location[mProvider=gps,mTime=-1000,mLatitude=25.0,mLongitude=23.0,mHasAltitude=true,mAltitude=0.0,mHasSpeed=false,mSpeed=0.0,mHasBearing=false,mBearing=0.0,mHasAccuracy=false,mAccuracy=0.0,mExtras=Bundle[mParcelledData.dataSize=52]]
10-02 17:22:49.444: INFO/gps(6671): Provider gps is has status changed to 2. Extras: Bundle[mParcelledData.dataSize=52]

据的http://developer.android.com/reference/android/location/LocationProvider.html#AVAILABLE ,即2映射到可用。

According to http://developer.android.com/reference/android/location/LocationProvider.html#AVAILABLE , that 2 maps to "Available".

只要是可用被设定,没有其他地方获得通过。似乎有点违反直觉。

As soon as that "Available" gets set, no other locations get passed through. Seems a bit counterintuitive.

推荐答案

我相信你正在经历模拟器的GPS驱动程序的bug。

I believe you are experiencing a bug in the GPS driver of the emulator.

一个解决方法的1.5版本的SDK包含在的错误报告。从那里引述如下:

A workaround for the 1.5 versions of the SDK is included in the bug report. To quote from there:

在模拟器,在主屏幕上,preSS菜单 - >设置 - >   日期和放大器;时间 - >取消选中自动 - >选择时区,   并选择合适的时区(即你的)。

In the emulator, on the Home Screen, press "Menu" -> "Settings" -> "Date & Time" -> Uncheck "Automatic" -> "Select Time Zone", and choose the right time zone (ie, yours).

A <一个href="http://android.git.kernel.org/?p=platform/hardware/libhardware%5Flegacy.git;a=commit;h=613d25b8c0fd1ab92c566d965e3cd7da85c31ee0"相对=nofollow>修复包含在1.6版本的SDK。

A fix is included in the 1.6 release of the SDK.

这篇关于手动添加位置更新停止在Eclipse工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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