List of usage examples for android.content Context LOCATION_SERVICE
String LOCATION_SERVICE
To view the source code for android.content Context LOCATION_SERVICE.
Click Source Link
From source file:com.nadmm.airports.LocationListFragmentBase.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); mRadius = Integer.valueOf(prefs.getString(PreferencesActivity.KEY_LOCATION_NEARBY_RADIUS, "30")); Bundle args = getArguments();// w w w . j a v a2 s . co m if ((args != null) && args.containsKey(DatabaseManager.LocationColumns.LOCATION)) { mLastLocation = args.getParcelable(DatabaseManager.LocationColumns.LOCATION); if (mLastLocation != null) { // A location is passed so current location is not needed mLocationUpdatesEnabled = false; } } else { mLastLocation = null; } if (mLocationUpdatesEnabled) { mLocationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); if (mLocationManager == null) { mLocationUpdatesEnabled = false; } } }
From source file:com.example.android.camera2video.CameraActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera); if (null == savedInstanceState) { getFragmentManager().beginTransaction().replace(R.id.container, Camera2VideoFragment.newInstance()) .commit();/* w ww . ja v a 2 s . c o m*/ } mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, TAG_PERMISSION_FINE_LOCATION); } else { mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0f, this); } mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mAccSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mSensorManager.registerListener(this, mAccSensor, SensorManager.SENSOR_DELAY_GAME); // mGraSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY); // mSensorManager.registerListener(this, mGraSensor, SensorManager.SENSOR_DELAY_GAME); // mLinSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION); // mSensorManager.registerListener(this, mLinSensor, SensorManager.SENSOR_DELAY_GAME); // mGyrSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); // mSensorManager.registerListener(this, mGyrSensor, SensorManager.SENSOR_DELAY_GAME); mUgySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE_UNCALIBRATED); mSensorManager.registerListener(this, mUgySensor, SensorManager.SENSOR_DELAY_GAME); // mMagSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); // mSensorManager.registerListener(this, mMagSensor, SensorManager.SENSOR_DELAY_GAME); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mPowerManager = (PowerManager) getSystemService(POWER_SERVICE); mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName()); mWakeLock.acquire(); }
From source file:com.duy.pascal.interperter.libraries.android.gps.AndroidLocationLib.java
public AndroidLocationLib(AndroidLibraryManager manager) { if (manager.getContext() != null) { mContext = manager.getContext(); mGeocoder = new Geocoder(mContext); mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); mLocationUpdates = new HashMap<>(); }/* w ww . ja v a 2 s . c o m*/ }
From source file:com.boundlessgeo.spatialconnect.scutilities.LocationHelper.java
public LocationHelper(Context context) { this.context = context; locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); }
From source file:com.platform.GeoLocationManager.java
public void getOneTimeGeoLocation(Continuation cont, Request req) { this.continuation = cont; this.baseRequest = req; final MainActivity app = MainActivity.app; if (app == null) return;//from w w w .j ava 2s .c o m locationManager = (LocationManager) app.getSystemService(Context.LOCATION_SERVICE); if (locationManager == null) { Log.e(TAG, "getOneTimeGeoLocation: locationManager is null!"); return; } app.runOnUiThread(new Runnable() { @Override public void run() { if (ActivityCompat.checkSelfPermission(app, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(app, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { RuntimeException ex = new RuntimeException("getOneTimeGeoLocation, can't happen"); Log.e(TAG, "run: getOneTimeGeoLocation, can't happen"); FirebaseCrash.report(ex); return; } locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); } }); }
From source file:com.danvelazco.android.wear.emergencyalert.service.WearAlertService.java
/** * {@inheritDoc}/* w w w . j a v a 2s. c o m*/ */ @Override public void onCreate() { super.onCreate(); mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); }
From source file:at.ac.tuwien.caa.docscan.camera.LocationHandler.java
private LocationHandler(Context context) { mContext = context;/*from ww w.ja v a 2 s.c o m*/ mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { boolean stopManager = false; // Called when a new location is found: if (isBetterLocation(location, mLocation)) { mLocation = location; if (mLocation.getAccuracy() <= MIN_ACCURACY) stopManager = true; } if (System.currentTimeMillis() - mStartTime >= MAX_TIME_RUNNING) stopManager = true; if (stopManager && ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) mLocationManager.removeUpdates(this); } public void onStatusChanged(String provider, int status, Bundle extras) { } public void onProviderEnabled(String provider) { } public void onProviderDisabled(String provider) { } }; if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { List<String> providers = mLocationManager.getProviders(true); if (providers.contains(LocationManager.NETWORK_PROVIDER)) mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, UPDATE_TIME, UPDATE_DISTANCE, locationListener); if (providers.contains(LocationManager.GPS_PROVIDER)) mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, UPDATE_TIME, UPDATE_DISTANCE, locationListener); mStartTime = System.currentTimeMillis(); } }
From source file:it.ms.theing.loquitur.functions.LocationInterface.java
public LocationInterface(Loquitur activity) { locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE); context = activity; }
From source file:com.simadanesh.isatis.CommonPlace.java
public void StartLocationManager(Context context) { if (locationManager == null) { locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); }/* w w w . ja v a 2s .c o m*/ }
From source file:com.jmstudios.redmoon.receiver.LocationUpdateListener.java
@Override public void onProviderDisabled(String provider) { if (DEBUG)//w w w. j av a 2 s .c o m Log.i(TAG, "Location search failed"); LocationManager locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) locationManager.removeUpdates(this); if (mPreference != null) mPreference.handleLocationSearchFailed(); }