I am developing an Android application that allows you to make fun of your location without including it in the developerโs settings.
I tried several things to do this, but without any success.
My actual code works if the parameter is enabled but not disabled (even if the application is a system application)
My code is:
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());
Did I do something wrong? I, unfortunately, do not know how to do this when you have rights to the system / application.
Do you have any suggestions for solving it? I do not need a fully working program code, just how it can be done.
Thank you for your help!
source share