本文整理匯總了Java中android.location.LocationManager.PASSIVE_PROVIDER屬性的典型用法代碼示例。如果您正苦於以下問題:Java LocationManager.PASSIVE_PROVIDER屬性的具體用法?Java LocationManager.PASSIVE_PROVIDER怎麽用?Java LocationManager.PASSIVE_PROVIDER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.location.LocationManager
的用法示例。
在下文中一共展示了LocationManager.PASSIVE_PROVIDER屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LogHelper.verboseLog(TAG,
"File name: \"" +
Thread.currentThread().getStackTrace()[2].getFileName() +
"\", Line number: " +
Thread.currentThread().getStackTrace()[2].getLineNumber() +
", Class name: \"" +
Thread.currentThread().getStackTrace()[2].getClassName() +
"\", Method name: \"" +
Thread.currentThread().getStackTrace()[2].getMethodName() +
"\"");
if (Configuration.sIsFeatureLocationAvailable) {
if (Configuration.sIsFeatureLocationNetworkAvailable) {
mNetworkProvider = LocationManager.NETWORK_PROVIDER;
}
if (Configuration.sIsFeatureLocationGpsAvailable) {
mGpsProvider = LocationManager.GPS_PROVIDER;
}
mPassiveProvider = LocationManager.PASSIVE_PROVIDER;
}
}
示例2: initLocation
private void initLocation() {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
List<String> providers = mLocationManager.getProviders(true);
String locationProvider;
/**
* 如果首選GPS定位,會存在這種情況,上次GPS啟動采集數據在A地,本次在B地需要定位,但用戶恰好在室內無
* GPS信號,隻好使用上次定位數據,就出現了地區級偏差。而網絡定位則更具有實時性,在精度要求不高以及室內
* 使用場景更多的前提下,首選網絡定位
*/
if (providers.contains(LocationManager.NETWORK_PROVIDER)) {
locationProvider = LocationManager.NETWORK_PROVIDER; // 首選網絡定位
} else if (providers.contains(LocationManager.GPS_PROVIDER)) {
locationProvider = LocationManager.GPS_PROVIDER;
} else {
locationProvider = LocationManager.PASSIVE_PROVIDER;
}
if (mLocationListener != null)
mLocationManager.requestLocationUpdates(locationProvider, 2000, 10, mLocationListener);
}
示例3: update
@Override
public void update() {
currentProvider = LocationManager.PASSIVE_PROVIDER;
}