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);
}
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();
}
}
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;
}
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);
}
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);
}
Aggregations