I have an application in which I am getting current location at the first page. In India Application is working fine and getting current location. When we run the application in US, application is getting crashed at the first page itself and throwing IllegalArgumentException.
Asked
Active
Viewed 729 times
2

Aju
- 4,597
- 7
- 35
- 58
1 Answers
2
The phone doesn't have any provider enabled to detect the location, i.e it is neither connected to GPS
nor WI-FI
, in which case the provider is being passed as null. This is assuming that you are providing provider
argument to requestLocationUpdates()
function by, finding the best provider, which will return null, if it can't find any.
I would first check if any provider is enabled, before proceeding any further in to this matter. To avoid passing null as a provider, check if the provider is null before calling for location update.
if (provider != null) {
requestLocationUpdates()
} else {
// alert user asking him to enable one of the providers.
}
This is how you do it.
HTH.

Yashwanth Kumar
- 28,931
- 15
- 65
- 69
-
Thanks.... do u have any sample code regarding setting the provider. If so please post it, it is helpful for me – Aju Sep 22 '11 at 09:50
-
i would see your code, before posting anything, like how are detecting the provider, and passing the provider to requestLocationUpdates() – Yashwanth Kumar Sep 22 '11 at 09:51
-
First time I am implementing location based thing, so I am not sure with the provider...give ur email id i will send the code – Aju Sep 22 '11 at 09:57
-
Sorry I am not able to find your emailid in your profile, only website address is there, no emailid – Aju Sep 22 '11 at 10:04
-
let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/3690/discussion-between-aju-vidyadharan-and-yashwanth-kumar) – Aju Sep 22 '11 at 10:21