Mock location does not work in Android Studio Emulator

♀尐吖头ヾ 提交于 2019-12-12 02:09:44

问题


From reading this guide, I tried to send gps location to the emulator, but it doesn't work. I tried with Google Maps. The emulator info: Nexus 5, API Level 19, Kitkat 4.4

A screen shot: (click send but nothing happens)


回答1:


You can use mock location in your app, I don't think it will work google maps as it won't have permission to use mock location. You have to declare android.permission.ACCESS_MOCK_LOCATION in manifest.

Get the location using

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


来源:https://stackoverflow.com/questions/39204953/mock-location-does-not-work-in-android-studio-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!