在Android 2.3.1和2.3.3上获取GPS

时间:2012-01-16 19:15:46

标签: android gps osmdroid openstreetmap

我在Android模拟器2.3.1和2.3.3中捕获GPS坐标时遇到问题,我测试了它的工作原理其他版本不明白在这两个版本的Android中没有读取坐标,我正在这样做激活GPS是这样的:

LocationManager lmgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

if (!lmgr.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {
        Intent myIntent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
    startActivity(myIntent);
}

lmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 10,this);

的AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

通过logcat仿真器发送GPS坐标给出以下系统并重新启动仿真器:

01-16 19:09:09.403: E/InputQueue-JNI(320): channel '406f3310 irbu.lod/irbu.lod.mapa.ViewMapaActivity (client)' ~ Publisher closed input channel or an error occurred.  events=0x8
01-16 19:09:09.403: E/InputQueue-JNI(320): channel '40819c60 irbu.lod/irbu.lod.IRBUActivity (client)' ~ Publisher closed input channel or an error occurred.  events=0x8
01-16 19:09:09.444: E/InputQueue-JNI(115): channel '406479d8 StatusBar (client)' ~ Publisher closed input channel or an error occurred.  events=0x8
01-16 19:09:09.444: E/InputQueue-JNI(115): channel '4063cca0 TrackingView (client)' ~ Publisher closed input channel or an error occurred.  events=0x8
01-16 19:09:09.444: E/InputQueue-JNI(115): channel '40642858 StatusBarExpanded (client)' ~ Publisher closed input channel or an error occurred.  events=0x8
01-16 19:09:09.524: E/InputQueue-JNI(137): channel '407d5158 com.android.launcher/com.android.launcher2.Launcher (client)' ~ Publisher closed input channel or an error occurred.  events=0x8
01-16 19:10:36.427: E/Zygote(363): setreuid() failed. errno: 17

可以在不重启的情况下读取GPS坐标吗?

2 个答案:

答案 0 :(得分:1)

这是一个报告here的错误。

答案 1 :(得分:0)

尝试使用SDK 2.1。我认为这是android 2.3.1中的一个错误