I am trying to work with NETWORK and the GPS location provider at the same time. In the main action, I register a 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), incoming calls are executed:
@Override
public void onReceive(Context context, Intent intent) {
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: how to determine from which provider this intention came from? (String provider_name = ???;)
I try at the time of registration to include in the name of the provider of intent as a payload as follows:
intent.putExtra("local.home.gpstest.PROVIDER", provider);
but to no avail: the provider’s incoming intent deletes my data ...
source
share