我正在使用被動提供商,使用此代碼。Google地圖和被動提供商
Intent intent = new Intent(PASSIVE_ACTION);
PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
mLocationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, pi);
和我在AndroidManifest.xml限定廣播接收機
<receiver
android:name="passiveLocationReceiver"
android:enabled="true" >
<intent-filter>
<action android:name="com.passive_location_update" />
</intent-filter>
</receiver>
passiveLocationReceiver是
public class passiveLocationReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (!PASSIVE_ACTION.equals(action))
return;
Log.d("chitacan","Passive Provider Event!!!");
}
}
此代碼工作正常時其他地理位置應用程序(臉譜,四角..等) 但是使用「Google Map」應用程序,它不會。(d.android.com解釋「PASSIVE_PROVIDER」,當其他應用程序可以更新時equests位置。)
即使我可以看到我的位置。「谷歌地圖」應用程序,但我無法擺脫被動提供商的任何事件。(我不能看到passiveLocationReceiver的日誌信息。)
好,我試圖在命令行轉儲LocationManager的狀態,
$adb shell dumpsys location
但是LocationManager的狀態沒有改變任何東西。似乎「Google地圖」應用程序 未使用LocationManager。
有沒有什麼辦法讓被動活動時,「谷歌地圖」應用程序更新我的位置? 還是我做錯了什麼?
...但是,您無法確定位置是來自GPS或網絡還是具有融合位置的WiFi。 – 2014-12-12 15:14:25