[英]LocationManager Provider Types?
我正在嘗試
LocationManager<\/code><\/a> 。
它在文檔中僅列出了 3 個提供商
GPS|NETWORK|PASSIVE_PROVIDER<\/code> 。
我使用
criteria<\/code>來獲得最佳的位置更新。
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
locationManager.requestLocationUpdates(0, 0, criteria, locationListener, null);
我還沒有看到這個特定的問題,但從 Android 11 開始,在某些設備上似乎
getBestProvider<\/code>可以返回
fused<\/code>並且
getProviders()<\/code>也可以。
值得注意的是,
PROVIDER_FUSED<\/code>作為常量添加到 Api 31
https:\/\/developer.android.com\/reference\/android\/location\/LocationManager#FUSED_PROVIDER<\/a>
無論如何,我對
getProviders(true)<\/code>和
getBestProviders(Criteria(FINE_LOCATION), true)<\/code>進行了一些測試,這可能證明是有用的:
MotoX Android 5.1
01-28 10:23:11.575 23263-23263 D: Providers: passive gps network
01-28 10:23:11.575 23263-23263 D: Best Provider: gps
Galaxy S9 Android 9
2022-01-28 12:27:24.781 -0500 14129 14129 D: Providers: passive gps network
2022-01-28 12:27:24.781 -0500 14129 14129 D: Best Provider: gps
Galaxy A20 Androi 10
2022-01-28 12:34:53.038 -0500 23114 23114 D: Providers: passive network gps
2022-01-28 12:34:53.040 -0500 23114 23114 D: Best Provider: gps
Motorola Razr Android 11
2022-01-28 23:08:07.003 +0530 29548 29548 D: Providers: passive network gps
2022-01-28 23:08:07.004 +0530 29548 29548 D: Best Provider: gps
Pixel 3a XL Android 12
2022-01-28 12:31:47.386 -0500 20145 20145 D: Providers: passive network fused gps
2022-01-28 12:31:47.387 -0500 20145 20145 D: Best Provider: fused
Pixel 3 Android 12
2022-01-28 10:39:55.397 10580-10580 D: Providers: passive network fused gps
2022-01-28 10:39:55.397 10580-10580 D: Best Provider: fused
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.