java.lang.IllegalArgumentException: provider doesn't exist: gps

Viewed 8622

Am using GPS to get the Users Location, In Samsung Galaxy S5(klte) with Android 5.0 shows error like java.lang.IllegalArgumentException: provider doesn't exist: gps but the device have GPS. Can tell Whats the error Exactly denotes like no GPS or Not able to access the GPS.

Can anyone know help me out to solve this issue.

Error Log

Caused by: java.lang.IllegalArgumentException: provider doesn't exist: gps
at android.os.Parcel.readException(Parcel.java:1544)
at android.os.Parcel.readException(Parcel.java:1493)
at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:584)
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:867)
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:459)
at melbourne.webdesign.karmaridedriver.Driver_location_update.onStartCommand(Driver_location_update.java:62)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3259)
... 9 more

Driver_location_update.java:62

denotes below Line

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 4000, 0, listener);
3 Answers

Network or GPS provider doesn't exist on some devices, so if you start corresponding services, it doesn't work. It's better to check with an if statement like this:

if(locationManager.getAllProviders().contains("network")) {
     locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, time, distance, this);
}

worked perfectly fine

Related