use of android.location.LocationProvider in project android_frameworks_base by crdroidandroid.
the class LocationManagerTest method testGetGpsProvider.
public void testGetGpsProvider() {
LocationProvider p = manager.getProvider("gps");
assertNotNull(p);
}
use of android.location.LocationProvider in project android_frameworks_base by crdroidandroid.
the class LocationManagerTest method testGpsTracklog.
public void testGpsTracklog() {
LocationProvider p = manager.getProvider("gps");
assertNotNull(p);
// TODO: test requestUpdates method
}
use of android.location.LocationProvider in project android_frameworks_base by AOSPA.
the class LocationManagerTest method testGetBogusProvider.
public void testGetBogusProvider() {
LocationProvider p = manager.getProvider("bogus");
assertNull(p);
}
use of android.location.LocationProvider in project android_frameworks_base by AOSPA.
the class LocationManagerTest method testGetGpsProvider.
public void testGetGpsProvider() {
LocationProvider p = manager.getProvider("gps");
assertNotNull(p);
}
use of android.location.LocationProvider in project android_packages_apps_OmniClock by omnirom.
the class AddCityDialog method requestLocation.
private void requestLocation() {
Looper looper = mContext.getMainLooper();
mHandler.postDelayed(mLocationTimeout, LOCATION_REQUEST_TIMEOUT);
mLocationRequesting = true;
mCityName.setEnabled(false);
mCityName.setText(org.omnirom.deskclock.R.string.cities_add_searching);
mTimeZones.setEnabled(false);
mGps.setImageResource(org.omnirom.deskclock.R.drawable.ic_gps_anim);
try {
((AnimationDrawable) mGps.getDrawable()).start();
} catch (Exception ex) {
// Ignore
}
if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
Location location = mLocationMgr.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
if (location != null && location.getAccuracy() > LOCATION_ACCURACY_THRESHOLD_METERS) {
location = null;
}
// If lastKnownLocation is not present (because none of the apps in the
// device has requested the current location to the system yet) or outdated,
// then try to get the current location use the provider that best matches the criteria.
boolean needsUpdate = location == null;
if (location != null) {
long delta = System.currentTimeMillis() - location.getTime();
needsUpdate = delta > OUTDATED_LOCATION_THRESHOLD_MILLIS;
}
if (needsUpdate) {
String locationProvider = mLocationMgr.getBestProvider(sLocationCriteria, true);
if (locationProvider != null) {
LocationProvider lp = mLocationMgr.getProvider(locationProvider);
if (lp != null) {
mLocationMgr.requestSingleUpdate(locationProvider, this, looper);
}
}
} else {
onLocationChanged(location);
}
}
}
Aggregations