is Gps Enabled - Android Map

Android examples for Map:GPS

Description

is Gps Enabled

Demo Code


//package com.java2s;

import android.content.Context;

import android.location.LocationManager;

import android.provider.Settings;
import android.util.Log;

public class Main {
    /**//  www  .j ava2 s .  c om
     * @return true if GPS location is opened,or false
     */
    public static boolean isGpsEnabled(Context context) {
        String str1 = Settings.Secure.getString(
                context.getContentResolver(),
                Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
        Log.v("GPS", str1);
        if (str1 != null) {
            return str1.contains(LocationManager.GPS_PROVIDER);
        } else {
            return false;
        }
    }
}

Related Tutorials