I’m working with passive provider, with this code.
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);
and I define broadcast receiver in AndroidManifest.xml
<receiver
android:name="passiveLocationReceiver"
android:enabled="true" >
<intent-filter>
<action android:name="com.passive_location_update" />
</intent-filter>
</receiver>
passiveLocationReceiver is
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!!!");
}
}
This code works fine when other geo location applications(facebook, foursquare.. etc)
But with “Google Map” application, It doesn’t.(d.android.com explains “PASSIVE_PROVIDER” that can be updated when other application requests locations.)
Even though I can see my location with “Google Map” application, but I can’t get any event from passive provider.(I can’t see passiveLocationReceiver’s log message.)
Well, I tried to dump LocationManager’s state in command line,
$adb shell dumpsys location
However LocationManager’s state didn’t change anything. Seems like “Google Map” Application
doesn’t use LocationManager.
Is there any way to get passive event when “Google Map” application updates my location??
or Am I doing something wrong??
requestLocationUpdates will only receive changes or “updates” to location values. Google Maps will broadcast changes in location values that are provided by the GPS Location provider.
If testing from an Emulator, try entering a new value for your mock location. Otherwise, test while walking around.
However, I have noticed too that Wi-Fi (network) locations changes are not broadcast from Google Maps like they are from other similar apps.
In your case- perhaps the GPS is not enabled, or it hasn’t changed location from its current state and therefore you are not receiving any “updates” in location to this listener. (I found this topic because I was wondering why Google Maps was not broadcasting Wi-Fi location changes if anyone figures that out)