I try work with NETWORK and GPS location provider simultaneously. In main activity I register location update request for each available provider:
for (String provider : m_lm.getProviders(false)) {
Intent intent = new Intent(GpsMain.this, GpsTestReceiver.class);
PendingIntent pi = PendingIntent.getBroadcast(GpsMain.this,0, intent, 0);
m_lm.requestLocationUpdates(provider, 60000, 10, pi);
}
In my BroadcastReceiver (GpsTestReceiver) do incoming Intent handling:
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Bundle ex = intent.getExtras();
if (ex.containsKey(LocationManager.KEY_STATUS_CHANGED)) {
int status = (Integer)ex.get(LocationManager.KEY_STATUS_CHANGED);
String str_status;
switch (status) {
case 1:
str_status = "TEMPORARILY_UNAVAILABLE";
break;
case 2:
str_status = "AVAILABLE";
break;
default:
str_status = "OUT_OF_SERVICE";
break;
}
String provider_name = ???;
s = provider_name+": change status into "+str_status+"\n";
}
}
Question is: how to determine from which provider arrived this intent? (String provider_name = ???;)
I try at registration moment include in the intent provider name as a payload like this:
intent.putExtra("local.home.gpstest.PROVIDER", provider);
but unsuccessfully: incoming intent from provider erase my data...