本文整理汇总了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;
}