Search in sources :

Example 11 with LocationProvider

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);
}
Also used : LocationProvider(android.location.LocationProvider)

Example 12 with LocationProvider

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
}
Also used : LocationProvider(android.location.LocationProvider)

Example 13 with LocationProvider

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);
}
Also used : LocationProvider(android.location.LocationProvider)

Example 14 with LocationProvider

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);
}
Also used : LocationProvider(android.location.LocationProvider)

Example 15 with LocationProvider

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);
        }
    }
}
Also used : Looper(android.os.Looper) LocationProvider(android.location.LocationProvider) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Location(android.location.Location)

Aggregations

LocationProvider (android.location.LocationProvider)27 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 AnimationDrawable (android.graphics.drawable.AnimationDrawable)1 Criteria (android.location.Criteria)1 Location (android.location.Location)1 LocationManager (android.location.LocationManager)1 Looper (android.os.Looper)1 IOException (java.io.IOException)1