List of usage examples for android.location LocationManager GPS_PROVIDER
String GPS_PROVIDER
To view the source code for android.location LocationManager GPS_PROVIDER.
Click Source Link
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 {//from w w w . j av a 2 s. c om return false; } }
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 isGpsOn(Context context) { boolean result = false; final LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); try {//w w w . java2s .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
/** * * @param activity// ww w . j a va2 s . co m * @return */ public static boolean isGPSEnabled(Activity activity) { final LocationManager manager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE); if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { return true; } return false; }
From source file:Main.java
public static Location getLocation(Context context) { try {//from w ww .j a v a2 s.c o m LocationManager locMan = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location location = locMan.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location == null) { location = locMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } return location; } catch (Exception e) { } return null; }
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); }//from w w w . j a v a2 s . co m return false; }
From source file:Main.java
public static boolean deviceSupportGPS(Context context) { boolean result = false; final LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); List<String> allProviders = manager.getAllProviders(); if (allProviders.contains(LocationManager.GPS_PROVIDER)) { result = true;//w w w. jav a2 s. c o m } return result; }
From source file:Main.java
/** * Is gPS enabled./*from w ww . j av a2 s . co m*/ * * @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 boolean checkLocationService(Context context) { LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); boolean gps_enabled = false; boolean network_enabled = false; try {/*from w w w.j av a2s. c o m*/ gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER); } catch (Exception ex) { } try { network_enabled = lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER); } catch (Exception ex) { } return gps_enabled; }
From source file:Main.java
/** Returns true if GPS provider is enabled, otherwise false. */ public static final boolean isGpsEnabled() { loadLocationManager();//w w w . j a v a 2 s .co m try { return mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); } catch (Exception e) { return false; } }