Example usage for android.content Context LOCATION_SERVICE

List of usage examples for android.content Context LOCATION_SERVICE

Introduction

In this page you can find the example usage for android.content Context LOCATION_SERVICE.

Prototype

String LOCATION_SERVICE

To view the source code for android.content Context LOCATION_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.location.LocationManager for controlling location updates.

Usage

From source file:Main.java

public static boolean isGpsEnabled() {
    LocationManager lm = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
    return lm.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 isGPSEnabled(Context cxt) {
    LocationManager locationManager = ((LocationManager) cxt.getSystemService(Context.LOCATION_SERVICE));
    List<String> accessibleProviders = locationManager.getProviders(true);
    return accessibleProviders != null && accessibleProviders.size() > 0;
}

From source file:Main.java

public static boolean supportGps(Context context) {
    final LocationManager mgr = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    if (mgr != null) {
        List<String> providers = mgr.getAllProviders();
        return providers != null && providers.contains(LocationManager.GPS_PROVIDER);
    }//  w  ww  .  j  ava  2s. c om
    return false;
}

From source file:Main.java

public static boolean checkLocationService(String providers, Context context) {
    LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    return locationManager.isProviderEnabled(providers);
}

From source file:Main.java

public static boolean isGpsEnabled(Context context) {
    LocationManager locationManager = ((LocationManager) context.getSystemService(Context.LOCATION_SERVICE));
    List<String> accessibleProviders = locationManager.getProviders(true);
    return accessibleProviders != null && accessibleProviders.size() > 0;
}

From source file:Main.java

public static final boolean isGPSOPen(final Context context) {
    LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
    // if (gps ) {
    // return true;
    // }//from w ww  .  j  a  v a2  s.  co  m
    if (gps || network) {
        return true;
    }
    return false;
}

From source file:Main.java

public static boolean checkGPSStatus(Context context) {
    boolean resp = false;
    LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        resp = true;//from   w w  w .  ja  v  a  2  s  . c  o m
    }
    return resp;
}

From source file:Main.java

public static boolean isGpsConnected(Context context) {
    boolean resp = false;
    LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        resp = true;/*w  w w .j  av a 2 s .co m*/
    }
    return resp;
}

From source file:Main.java

public static boolean isLocationEnabled(Context context) {
    try {//from   w  ww  .ja va2 s  . c om
        LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
                || locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}