本文整理匯總了Java中android.location.Criteria.setAltitudeRequired方法的典型用法代碼示例。如果您正苦於以下問題:Java Criteria.setAltitudeRequired方法的具體用法?Java Criteria.setAltitudeRequired怎麽用?Java Criteria.setAltitudeRequired使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.location.Criteria
的用法示例。
在下文中一共展示了Criteria.setAltitudeRequired方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCriteria
import android.location.Criteria; //導入方法依賴的package包/類
/**
* 設置定位參數
*
* @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;
}
示例2: getCriteria
import android.location.Criteria; //導入方法依賴的package包/類
/**
* 設置定位參數
*
* @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;
}
示例3: setupLocationListener
import android.location.Criteria; //導入方法依賴的package包/類
@SuppressLint("MissingPermission")
private void setupLocationListener() {
locationListener = new LocationListener();
locationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
TIME_TO_UPDATE = Integer.parseInt(sharedPreferences.getString("sync_frequency", "60")) * 1000;
Criteria criteria = new Criteria();
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(true);
criteria.setSpeedRequired(false);
criteria.setPowerRequirement(Criteria.POWER_LOW);
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setCostAllowed(true);
bestProvider = locationManager.getBestProvider(criteria, false);
locationManager.requestLocationUpdates(bestProvider, TIME_TO_UPDATE, DISTANCE_TO_CHANGE, locationListener);
}
示例4: setupLocationChangeListener
import android.location.Criteria; //導入方法依賴的package包/類
@SuppressLint("MissingPermission")
private void setupLocationChangeListener() {
/* SETTING UP LOCATION CHANGE LISTENER */
locationListener = new LocationListener();
locationManager = (LocationManager) Application.getContext().getSystemService(Context.LOCATION_SERVICE);
locationServiceEnabled = locationManager != null && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
Criteria criteria = new Criteria();
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(true);
criteria.setSpeedRequired(false);
criteria.setPowerRequirement(Criteria.POWER_LOW);
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setCostAllowed(true);
bestProvider = locationManager.getBestProvider(criteria, false);
updateFrequency = Integer.parseInt(settingsSharedPreferences.getString("update_frequency", "5")) * 1000;
locationManager.requestLocationUpdates(bestProvider, updateFrequency, 0, locationListener);
}
示例5: initServices
import android.location.Criteria; //導入方法依賴的package包/類
private void initServices() {
// sensor manager
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mOrientationSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
// location manager
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
mLocationProvider = mLocationManager.getBestProvider(criteria, true);
}
示例6: getProviderName
import android.location.Criteria; //導入方法依賴的package包/類
/**
* Get the best provider name.
* @return Name of best suiting provider.
* */
String getProviderName() {
LocationManager locationManager = (LocationManager) this
.getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setPowerRequirement(Criteria.POWER_HIGH); // Chose your desired power consumption level.
criteria.setAccuracy(Criteria.ACCURACY_MEDIUM); // Choose your accuracy requirement.
criteria.setSpeedRequired(true); // Chose if speed for first location fix is required.
criteria.setAltitudeRequired(false); // Choose if you use altitude.
criteria.setBearingRequired(false); // Choose if you use bearing.
criteria.setCostAllowed(true); // Choose if this provider can waste money :-)
// Provide your criteria and flag enabledOnly that tells
// LocationManager only to return active providers.
return locationManager.getBestProvider(criteria, true);
}
示例7: GeoHelper
import android.location.Criteria; //導入方法依賴的package包/類
public GeoHelper(Context context) {
//Constructor
Log.i(TAG, "Initialize GeoHelper.");
mContext = context;
locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
listAllProviders();
criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
criteria.setAltitudeRequired(false);
criteria.setCostAllowed(false);
criteria.setPowerRequirement(Criteria.POWER_LOW);
criteria.setSpeedRequired(false);
chooseBestProvider();
}
示例8: getBestProvider
import android.location.Criteria; //導入方法依賴的package包/類
/**
* 獲取以下條件下,最合適的provider
*/
private void getBestProvider() {
Criteria criteria = new Criteria();
// 精度高
criteria.setAccuracy(Criteria.ACCURACY_FINE);
// 低消耗
criteria.setPowerRequirement(Criteria.POWER_LOW);
// 海拔
criteria.setAltitudeRequired(true);
// 速度
criteria.setSpeedRequired(true);
// 費用
criteria.setCostAllowed(false);
String provider = locationManager.getBestProvider(criteria, false); //false是指不管當前適配器是否可用
this.bestProviderTV.setText(provider);
}
示例9: GeoLocation
import android.location.Criteria; //導入方法依賴的package包/類
/**
* The constructor of the GeoLocation class and we supplied the Context as a parameter.
* initialize the application context. Criteria class indicating the application criteria for
* selecting a location provider. locationManager class provides access to the system location
* services. These services allow applications to obtain periodic updates of the device's
* geographical location
*/
public GeoLocation(Context ctx) {
context = ctx;
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
gpsStatus = false;
return;
} else {
gpsStatus = true;
}
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
provider = locationManager.getBestProvider(criteria, true);
locationManager.requestLocationUpdates(provider, 5000, 0, this);
}
示例10: toggleBestUpdates
import android.location.Criteria; //導入方法依賴的package包/類
public void toggleBestUpdates(View view) {
if(!checkLocation())
return;
Button button = (Button) view;
if(button.getText().equals(getResources().getString(R.string.pause))) {
locationManager.removeUpdates(locationListenerBest);
button.setText(R.string.resume);
}
else {
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String provider = locationManager.getBestProvider(criteria, true);
if(provider != null) {
locationManager.requestLocationUpdates(provider, 2 * 60 * 1000, 10, locationListenerBest);
button.setText(R.string.pause);
Toast.makeText(this, "Best Provider is " + provider, Toast.LENGTH_LONG).show();
}
}
}
示例11: onCreate
import android.location.Criteria; //導入方法依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
// 查詢條件
Criteria criteria = new Criteria();
// 精確度
criteria.setAccuracy(Criteria.ACCURACY_FINE);
// 關心海拔
criteria.setAltitudeRequired(true);
// 運行產生開銷
criteria.setCostAllowed(true);
// 允許最大電量請求
criteria.setPowerRequirement(Criteria.POWER_HIGH);
String provider = mLocationManager.getBestProvider(criteria, true);
Logger.i(TAG, "最好的提供者:" + provider);
mPhoneLocationListener = new PhoneLocationListener();
mLocationManager.requestLocationUpdates(provider, 0, 0, mPhoneLocationListener);
}
示例12: SensorsOrientationManager
import android.location.Criteria; //導入方法依賴的package包/類
/**
* Initializes a new instance of {@code OrientationManager}, using the specified context to
* access system services.
*/
public SensorsOrientationManager(SensorManager sensorManager, LocationManager locationManager) {
mRotationMatrix = new float[16];
mOrientation = new float[9];
mSensorManager = sensorManager;
mLocationManager = locationManager;
mListeners = new LinkedHashSet<OnChangedListener>();
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setBearingRequired(true);
criteria.setSpeedRequired(true);
criteria.setAltitudeRequired(true);
mLocationProvider = mLocationManager.getBestProvider(criteria, false);
}
示例13: onAccurateProvider
import android.location.Criteria; //導入方法依賴的package包/類
public void onAccurateProvider() {
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setSpeedRequired(true);
criteria.setAltitudeRequired(true);
LocationManager lm = (LocationManager) getActivity().getSystemService(
Context.LOCATION_SERVICE);
List<String> matchingProvideNames = lm.getProviders(criteria, false);
for (String providerName : matchingProvideNames) {
LocationProvider provider = lm.getProvider(providerName);
String logMessage = LogHelper.formationLocationProvider(
getActivity(), provider);
Log.d(_logTag, logMessage);
}
}
示例14: onCreate
import android.location.Criteria; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initializeGui();
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_COARSE); // GPS, Network, others
criteria.setPowerRequirement(Criteria.POWER_LOW);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setSpeedRequired(false);
criteria.setCostAllowed(true);
provider = locationManager.getBestProvider(criteria, true);
}
示例15: isLocationSharingAvailable
import android.location.Criteria; //導入方法依賴的package包/類
public static boolean isLocationSharingAvailable( Context context ) {
LocationManager manager = (LocationManager) context.getSystemService( Context.LOCATION_SERVICE );
if( manager == null ) {
return false;
}
Criteria criteria = new Criteria();
criteria.setAccuracy( Criteria.ACCURACY_FINE );
criteria.setAltitudeRequired( false );
criteria.setBearingRequired( false );
criteria.setCostAllowed( true );
criteria.setPowerRequirement( Criteria.NO_REQUIREMENT );
String provider = manager.getBestProvider( criteria, true );
if( provider == null || LocationManager.PASSIVE_PROVIDER.equals( provider ) ) {
return false;
}
return true;
}