Example usage for android.location LocationManager isProviderEnabled

List of usage examples for android.location LocationManager isProviderEnabled

Introduction

In this page you can find the example usage for android.location LocationManager isProviderEnabled.

Prototype

public boolean isProviderEnabled(String provider) 

Source Link

Document

Returns the current enabled/disabled status of the given provider.

Usage

From source file:Main.java

public static boolean isOpenGPS(Context context) {

    LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    boolean isGPSEnable = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    boolean isNPEnable = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

    return isGPSEnable || isNPEnable;

}

From source file:Main.java

public static boolean isNetworkLocation(Context context) {
    LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    return locationManager != null && locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
}

From source file:Main.java

public static boolean isGPSLocation(Context context) {
    LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    return locationManager != null && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}

From source file:Main.java

public static boolean isOpenGPS(Context context) {

    LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    boolean isGPSEnable = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    boolean isNPEnable = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

    if (isGPSEnable || isNPEnable)
        return true;

    return false;
}

From source file:Main.java

public static boolean isGpsOn(Context context) {
    LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    final boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    if (gpsEnabled) {
        return true;
    } else {/*  w w  w .j a v  a2  s.c o m*/
        return false;
    }
}

From source file:Main.java

/**
 * Is gPS enabled.//from w ww  .j a v a  2s  .com
 *
 * @param context the context
 * @return the boolean
 */
public static boolean isGPSEnabled(Context context) {
    final LocationManager locationManager = (LocationManager) context
            .getSystemService(Context.LOCATION_SERVICE);
    return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}

From source file:Main.java

public static String getGpsEnabled(Context context) {
    if (PackageManager.PERMISSION_GRANTED == context
            .checkCallingOrSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
        final LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        return Boolean.toString(manager.isProviderEnabled(LocationManager.GPS_PROVIDER));
    } else {/*from   w  w  w .  j av  a  2s . c o  m*/
        return null;
    }
}

From source file:it_minds.dk.eindberetningmobil_android.location.GpsMonitor.java

public static boolean isGpsEnabled(Context context) {
    LocationManager loc = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    return loc.isProviderEnabled(LocationManager.GPS_PROVIDER);
}

From source file:Main.java

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

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

    try {//from w w  w .  j av a 2s  .  c  o m
        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;
}

From source file:Main.java

public static void openGPS(Context context) {
    Log.d(TAG, "openGPS");
    LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

    if (!locationManager.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {
        Intent gpsIntent = new Intent();
        gpsIntent.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
        gpsIntent.addCategory("android.intent.category.ALTERNATIVE");
        gpsIntent.setData(Uri.parse("custom:3"));
        try {//from ww  w  . j a va  2  s .  co  m
            PendingIntent.getBroadcast(context, 0, gpsIntent, 0).send();

        } catch (CanceledException e) {
            Log.d(TAG, "openGPS exception:" + e.getMessage());

            e.printStackTrace();
        }

    }
}