How to tell if an Android device will be able to provide a location? -
i'm writing geo app , works nicely, i'm considering how it'll work on devices don't have gps or 3g, , wifi may off or not provide location info.
is best bet request location update (or use last known) , assume there way location (whether gps or network) or framework include way see what's available, , avoid geo-lookup delay?
i figure on device no gps app should provide ui user specify location, , remember in sharedprefs don't have keep re-entering (i'm thinking devices google tv, , tablets).
i'd appreciate suggestions on how handle process of acquiring location in context of various devices have different levels of geo-awareness, , how handle that.
you can invoke locationmanager.getallproviders()
retrieve location providers, or invoke locationmanager.getproviders(true)
retrieve active location providers.
boolean hasactivelocationprovider = false; locationmanager locationmanager = context.getsystemservice(context.location_service); list<string> providers = locationmanager.getproviders(true); (string providername:providers) { if (providername.equals(locationmanager.gps_provider) || providername.equals(locationmanager.network_provider)) { hasactivelocationprovider = true; } }
http://developer.android.com/reference/android/location/locationmanager.html
Comments
Post a Comment