安卓修改手机位置代码
1. 首先代码,在AndroidManifest.xm360问答l文件中添加以下权限:
<uses-permissio敌口迫鲁审而n android:nam集住践情美边远排e="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:na笔方简联构判me="android.pe孩村兴则酒业场培适次怀rmission.ACC思点格兵甲达ESS_FINE_LOCATION" />
2. 然后代码,在代码中添加以下代码:
LocationManager locationManager = (LocationManager) getSystemSer穿的权受音富vice(Context.LOCAT任起ION_SERVICE);
Location location = new Location("");
location.setLatitude(latitude);
location.s城etLongitude(longitude);
locationManager.setTestProviderLocation(Loca右讨三脱告养源负调于tionManager.GPS_PROVIDER, location);
其中,latitude和longitude是要改变的位置的经纬度值代码。
版权声明:如无特殊标注,文章均为本站原创,转载时请以链接形式注明文章出处。
评论