Search in sources :

Example 41 with Criteria

use of android.location.Criteria in project platform_frameworks_base by android.

the class LocationManagerTest method testGetBestProviderPowerCriteria.

public void testGetBestProviderPowerCriteria() {
    Criteria c = new Criteria();
    c.setPowerRequirement(Criteria.POWER_HIGH);
    String p = manager.getBestProvider(c, true);
    assertNotNull(p);
    c.setPowerRequirement(Criteria.POWER_MEDIUM);
    p = manager.getBestProvider(c, true);
    assertNotNull(p);
    c.setPowerRequirement(Criteria.POWER_LOW);
    p = manager.getBestProvider(c, true);
    assertNotNull(p);
    c.setPowerRequirement(Criteria.NO_REQUIREMENT);
    p = manager.getBestProvider(c, true);
    assertNotNull(p);
}
Also used : Criteria(android.location.Criteria)

Example 42 with Criteria

use of android.location.Criteria in project appsly-android-rest by 47deg.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    textViewDescription = (TextView) findViewById(R.id.textview_description);
    textViewTemp = (TextView) findViewById(R.id.textview_temp);
    imageViewIcon = (ImageView) findViewById(R.id.imageview_icon);
    textViewWind = (TextView) findViewById(R.id.textview_wind_response);
    textViewHumidity = (TextView) findViewById(R.id.textview_humidity_response);
    textViewTempMax = (TextView) findViewById(R.id.textview_tempmax_response);
    textViewTempMin = (TextView) findViewById(R.id.textview_tempmin_response);
    textViewCity = (TextView) findViewById(R.id.textview_city);
    contentProgressBar = (LinearLayout) findViewById(R.id.content_progressbar);
    linearLayoutContent = (LinearLayout) findViewById(R.id.content);
    contentBottom = (LinearLayout) findViewById(R.id.bottom_content);
    descriptionTempContent = (LinearLayout) findViewById(R.id.description_temp_content);
    RestClient client = RestClientFactory.defaultClient(getApplicationContext());
    api = RestServiceFactory.getService(getString(R.string.base_url), OpenWeatherAPI.class, client);
    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    String provider = locationManager.getBestProvider(criteria, false);
    Location location = locationManager.getLastKnownLocation(provider);
    checkImmersiveMode();
    if ((location != null) && checkConnection(getApplicationContext())) {
        setLocation(location);
    } else {
        failMessage();
    }
}
Also used : LocationManager(android.location.LocationManager) OpenWeatherAPI(ly.apps.android.rest.client.example.api.OpenWeatherAPI) Criteria(android.location.Criteria) Location(android.location.Location)

Example 43 with Criteria

use of android.location.Criteria in project AndroidUtilCode by Blankj.

the class LocationUtils method getCriteria.

/**
     * 设置定位参数
     *
     * @return {@link Criteria}
     */
private static Criteria getCriteria() {
    Criteria criteria = new Criteria();
    //设置定位精确度 Criteria.ACCURACY_COARSE比较粗略,Criteria.ACCURACY_FINE则比较精细
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    //设置是否要求速度
    criteria.setSpeedRequired(false);
    // 设置是否允许运营商收费
    criteria.setCostAllowed(false);
    //设置是否需要方位信息
    criteria.setBearingRequired(false);
    //设置是否需要海拔信息
    criteria.setAltitudeRequired(false);
    // 设置对电源的需求
    criteria.setPowerRequirement(Criteria.POWER_LOW);
    return criteria;
}
Also used : Criteria(android.location.Criteria)

Example 44 with Criteria

use of android.location.Criteria in project android_frameworks_base by AOSPA.

the class LocationManagerTest method testGetBestProviderEmptyCriteria.

public void testGetBestProviderEmptyCriteria() {
    String p = manager.getBestProvider(new Criteria(), true);
    assertNotNull(p);
}
Also used : Criteria(android.location.Criteria)

Example 45 with Criteria

use of android.location.Criteria in project android_frameworks_base by AOSPA.

the class LocationManagerTest method testGetBestProviderPowerCriteria.

public void testGetBestProviderPowerCriteria() {
    Criteria c = new Criteria();
    c.setPowerRequirement(Criteria.POWER_HIGH);
    String p = manager.getBestProvider(c, true);
    assertNotNull(p);
    c.setPowerRequirement(Criteria.POWER_MEDIUM);
    p = manager.getBestProvider(c, true);
    assertNotNull(p);
    c.setPowerRequirement(Criteria.POWER_LOW);
    p = manager.getBestProvider(c, true);
    assertNotNull(p);
    c.setPowerRequirement(Criteria.NO_REQUIREMENT);
    p = manager.getBestProvider(c, true);
    assertNotNull(p);
}
Also used : Criteria(android.location.Criteria)

Aggregations

Criteria (android.location.Criteria)52 Location (android.location.Location)20 Test (org.junit.Test)12 LocationManager (android.location.LocationManager)9 ArrayList (java.util.ArrayList)8 Bundle (android.os.Bundle)7 PendingIntent (android.app.PendingIntent)6 Intent (android.content.Intent)6 LocationListener (android.location.LocationListener)6 Handler (android.os.Handler)6 SuppressLint (android.annotation.SuppressLint)2 FacebookException (com.facebook.FacebookException)2 HashMap (java.util.HashMap)2 Prefs (nodomain.freeyourgadget.gadgetbridge.util.Prefs)2 PackageManager (android.content.pm.PackageManager)1 ResolveInfo (android.content.pm.ResolveInfo)1 EditTextPreference (android.preference.EditTextPreference)1 ListPreference (android.preference.ListPreference)1 Preference (android.preference.Preference)1 PreferenceCategory (android.preference.PreferenceCategory)1