【问题标题】:Mock location does not work in Android Studio Emulator模拟位置在 Android Studio 模拟器中不起作用
【发布时间】:2017-01-05 09:47:48
【问题描述】:

通过阅读this guide,我尝试将gps 位置发送到模拟器,但它不起作用。我试过谷歌地图。 模拟器信息:Nexus 5、API Level 19、Kitkat 4.4

屏幕截图:(点击发送但没有任何反应)

【问题讨论】:

    标签: android android-studio android-emulator


    【解决方案1】:

    您可以在您的应用程序中使用模拟位置,我认为它不适用于谷歌地图,因为它没有使用模拟位置的权限。您必须在清单中声明 android.permission.ACCESS_MOCK_LOCATION。

    获取位置使用

    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            if (locationManager.isProviderEnabled(GPS_MOCK_PROVIDER)) {
                locationManager.requestLocationUpdates(GPS_MOCK_PROVIDER, 0, 0f, this);
            }
    

    【讨论】:

      猜你喜欢
      • 2021-01-07
      • 2016-11-09
      • 1970-01-01
      • 1970-01-01
      • 2019-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多