模拟位置在Android Studio模拟器中不起作用 [英] Mock location does not work in Android Studio Emulator

查看:412
本文介绍了模拟位置在Android Studio模拟器中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过阅读本指南,我尝试向gps发送位置到仿真器,但它不起作用.我尝试使用Google地图. 模拟器信息:Nexus 5,API级别19,Kitkat 4.4

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)

推荐答案

您可以在应用中使用模拟位置,我认为它不会在google地图上运行,因为它没有使用模拟位置的权限.您必须在清单中声明android.permission.ACCESS_MOCK_LOCATION.

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.

使用获取位置

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

这篇关于模拟位置在Android Studio模拟器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆