List of usage examples for android.location LocationProvider getName
public String getName()
From source file:com.prey.services.LocationService.java
@Override public void onCreate() { PreyLogger.d("LocationService is going to be started..."); androidLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED)) { LocationProvider gpsLocationProvider = androidLocationManager.getProvider(LocationManager.GPS_PROVIDER); LocationProvider networkProvider = androidLocationManager.getProvider(LocationManager.NETWORK_PROVIDER); if (gpsLocationProvider != null && androidLocationManager.isProviderEnabled(gpsLocationProvider.getName())) { androidLocationManager.requestLocationUpdates(gpsLocationProvider.getName(), PreyConfig.UPDATE_INTERVAL, PreyConfig.LOCATION_PROVIDERS_MIN_REFRESH_DISTANCE, gpsLocationListener); PreyLogger.d("GPS Location provider has been started."); }/*from www . jav a 2 s .c o m*/ if (networkProvider != null && androidLocationManager.isProviderEnabled(networkProvider.getName())) { androidLocationManager.requestLocationUpdates(networkProvider.getName(), PreyConfig.UPDATE_INTERVAL / 4, PreyConfig.LOCATION_PROVIDERS_MIN_REFRESH_DISTANCE, networkLocationListener); PreyLogger.d("NETWORK Location provider has been started."); } } else { PreyLogger.i("___________ask for permission LocationService ACCESS_FINE_LOCATION"); } PreyLogger.d("LocationService has been started..."); }