Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (status)
Viewing all articles
Browse latest Browse all 62

GPS Status on Android

$
0
0

Hi all, i need to know if the GPS is enabled on Android. This is useless because return always true.

In native Java we have:

final LocationManager manager = (LocationManager) getSystemService( Context.LOCATION_SERVICE );
 
    if ( !manager.isProviderEnabled( LocationManager.GPS_PROVIDER )
and in Titanium there is a method for it but is protected in TiLocationHelper.java:
protected static boolean isValidProvider(String name)
{
    boolean enabled = (name.equals(LocationManager.GPS_PROVIDER) || name.equals(LocationManager.NETWORK_PROVIDER));
 
    if (enabled) {
        enabled = false;
 
        try{
            enabled = isLocationProviderEnabled(name);
        } catch(Exception ex){
            ex = null;
        } finally {
            if (!enabled) {
                Log.w(LCAT, "Preferred provider [" + name + "] isn't enabled on this device.  Will default to auto-select of GPS provider.");
            }
        }
    }
 
    return enabled;
}
Someone can help me?

Viewing all articles
Browse latest Browse all 62

Trending Articles