模拟位置在Android Studio模拟器中不起作用

时间:2016-08-29 11:17:05

标签: android android-studio android-emulator

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

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

1 个答案:

答案 0 :(得分:0)

您可以在自己的应用中使用模拟位置,但我认为它无法使用谷歌地图,因为它无法使用模拟位置。你必须在清单中声明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);
        }