Hi,
I want to send RINGER_MODE update to an activity using an alarm
manager and a BroadcastReceiver.
So, in the file which is listening to
"android.media.EXTRA_RINGER_MODE", I have this :
if(intent.getAction().equals("android.media.RINGER_MODE_CHANGED")) {
myAudio.setRingerMode(intent.getIntExtra
("android.media.EXTRA_RINGER_MODE", -1));
System.out.println("Changement de son: " +
Intent.getIntExtra
("android.media.EXTRA_RINGER_MODE", -1));
System.out.println("bla : " + getRingerMode());
sendRingerModeChangedBroadcast(getRingerMode());
}
...
Intent i = new Intent("com.tests.AudioInfo.RINGER_MODE_CHANGED");
i.putExtra("myMode", newMode);
PendingIntent broadcastSender =
PendingIntent.getBroadcast(context,
0, i, 0);
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime(), broadcastSender);
System.out.println("here: " + i.getIntExtra("myMode",
55));
...
And then in another file which receives it, I have :
public void onReceive(Context context, Intent intent) {
...
else if(intent.getAction().equals
("com.tests.AudioInfo.RINGER_MODE_CHANGED")) {
int newMode = intent.getIntExtra("myMode", 55);
System.out.println("there: " + newMode);
System.out.println("Ringer mode changed: " +
intent.getIntExtra
("myMode", 55));
}
So in "here:" and "there:" I should have the same value.
It works when this function is called for the first time but after,
"here:" is always followed by the new values whereas "there:" is
followed by the first value.
So the line int newMode = intent.getIntExtra("myMode", 55); does not
work anymore.
Could you explain to me why?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---