我正在使用被动提供商,使用此代码。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