is Gps On - Android Hardware

Android examples for Hardware:Gps

Description

is Gps On

Demo Code


//package com.java2s;

import android.content.Context;

import android.location.LocationManager;
import android.util.Log;

public class Main {
    public static boolean isGpsOn(Context context) {
        boolean result = false;

        final LocationManager manager = (LocationManager) context
                .getSystemService(Context.LOCATION_SERVICE);

        try {/*from  w w w  .  j  a  v  a2  s.c  om*/
            if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                result = true;
            }
        } catch (IllegalArgumentException e) {
            Log.d("GPS Helper",
                    "Looks like we do not have gps on the device");
        }

        return result;
    }
}

Related Tutorials