【问题标题】:Getting GPS on Android 2.3.1 and 2.3.3在 Android 2.3.1 和 2.3.3 上获取 GPS
【发布时间】:2012-01-16 19:15:45
【问题描述】:

我在 Android 模拟器 2.3.1 和 2.3.3 中捕获 GPS 坐标时遇到问题,我测试并且它工作其他版本不明白,在这 2 个版本的 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 坐标?

【问题讨论】:

  • 在 AVD 中创建模拟器时,是否确保将 GPS 作为其可用功能之一?
  • 感谢您的建议,我尝试放置 GPS 硬件的一个组件,但没有得到相同的结果,还有其他想法吗?

标签: android gps osmdroid openstreetmap


【解决方案1】:

这是 here 报告的错误。

【讨论】:

  • 不客气。我遇到了同样的问题,我最终使用了 API Level 7 (Android 2.1),一切都很好。你能把我的答案标记为“正确”吗? :)
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 2012-06-21
    • 2018-04-20
    • 1970-01-01
    • 2018-06-30
    • 1970-01-01
    • 2016-09-19
    • 1970-01-01
    • 2012-05-14
    • 1970-01-01
    相关资源
    最近更新 更多