Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无模拟位置设置的Android模拟位置(根设备)_Java_Android_Mocking_Location_Root - Fatal编程技术网

Java 无模拟位置设置的Android模拟位置(根设备)

Java 无模拟位置设置的Android模拟位置(根设备),java,android,mocking,location,root,Java,Android,Mocking,Location,Root,我正在为Android开发一个应用程序,它允许你模拟你的位置,而不需要在开发者设置中启用它 我尝试了几件事,但没有成功 我的实际代码在启用设置时有效,但在禁用设置时无效(即使应用程序是系统应用程序) 我的代码: if (mLocationManager.getProvider(GPS_PROVIDER_NAME) != null) { mLocationManager.removeTestProvider(GPS_PROVIDER_NAME); } mLocationManage

我正在为Android开发一个应用程序,它允许你模拟你的位置,而不需要在开发者设置中启用它

我尝试了几件事,但没有成功

我的实际代码在启用设置时有效,但在禁用设置时无效(即使应用程序是系统应用程序)

我的代码:

if (mLocationManager.getProvider(GPS_PROVIDER_NAME) != null) { 
    mLocationManager.removeTestProvider(GPS_PROVIDER_NAME); 
} 

mLocationManager.addTestProvider( 
            GPS_PROVIDER_NAME, 
            "requiresNetwork" == "", 
            "requiresSatellite" == "", 
            "requiresCell" == "", 
            "hasMonetaryCost" == "", 
            "supportsAltitude" == "", 
            "supportsSpeed" == "", 
            "supportsBearing" == "", 
            android.location.Criteria.POWER_LOW, 
            android.location.Criteria.ACCURACY_FINE 
); 

currentLocation = new Location(GPS_PROVIDER_NAME); 
currentLocation.setLatitude(mockLocationLatLng[0]); 
currentLocation.setLongitude(mockLocationLatLng[1]); 
currentLocation.setTime(System.currentTimeMillis()); 
currentLocation.setAltitude(1);
currentLocation.setSpeed(200); 
currentLocation.setAccuracy(500);

mLocationManager.setTestProviderLocation(GPS_PROVIDER_NAME, currentLocation); 
mLocationManager.setTestProviderEnabled(GPS_PROVIDER_NAME, true); 
mLocationManager.setTestProviderStatus(GPS_PROVIDER_NAME, LocationProvider.AVAILABLE, null, System.currentTimeMillis()); 
我做错什么了吗? 很遗憾,我不知道当你拥有系统/应用权限时该怎么办

你对如何解决这个问题有什么建议吗? 我不需要一个完全可以工作的程序代码,只需要一种方法

谢谢你的帮助