栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用模拟位置而不在设置中进行设置

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用模拟位置而不在设置中进行设置

我已经反编译了

com.lexa.fakegps
您提到的问题以及它的操作:

private int setMockLocationSettings() {    int value = 1;    try {        value = Settings.Secure.getInt(getContentResolver(),     Settings.Secure.ALLOW_MOCK_LOCATION);        Settings.Secure.putInt(getContentResolver(),     Settings.Secure.ALLOW_MOCK_LOCATION, 1);    } catch (Exception e) {        e.printStackTrace();    }    return value;}private void restoreMockLocationSettings(int restore_value) {    try {        Settings.Secure.putInt(getContentResolver(),     Settings.Secure.ALLOW_MOCK_LOCATION, restore_value);    } catch (Exception e) {        e.printStackTrace();    }}int value = setMockLocationSettings();//toggle ALLOW_MOCK_LOCATION ontry {    mLocationManager.setTestProviderLocation(LocationManager.GPS_PROVIDER, fake_location);} catch (SecurityException e) {    e.printStackTrace();} finally {    restoreMockLocationSettings(value);//toggle ALLOW_MOCK_LOCATION off}

由于这些代码的执行时间非常短,因此其他应用几乎无法检测到ALLOW_MOCK_LOCATION的更改。

另外,您还需要:
1.要求对设备具有root权限
2.将应用程序移至

/system/app
/system/priv-app

我在我的项目中尝试过,并且效果很好。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/487047.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号