Take a look at the docs for Location Provider. Try this code on multiple devices in different situations, and I think it should work:
try {
LocationProvider lp = LocationProvider.getInstance(null);
if (lp == null) {
} else {
}
} catch (LocationException le) {
}
source
share