android - Multiple calls to AlarmManager.setRepeating deliver the same Intent/PendingIntent extra values, but I supplied different ones -
It was sorted while writing this question, but it helps anyone in posting:
I am doing multiple settings like alarms, with different values of id
:
alarmmajor alarm = (alarmmanager) context.getSystemService (Context.ALARM_SERVICE); I = new intent (MyReceiver.ACTION_ALARM); // "com.example.ALARM" i.putExtra (MyReceiver.EXTRA_ID, ID); // "com.example.ID", 2 pending interpreter P = pending content.getbredcast (references, 0, i, 0); Alarms.setRepeating (AlarmManager.RTC_WAKEUP, Next Millise, 300000, P); // 5 minutes
... and get them in such a way:
receiver on public disclaimer (reference reference, intent to intent) {if (Intent.getAction (.ACULES (ACTION_ALARM)) {// This is the time of sound / an alarm final long id = intent.get lagextra (extra_id, -1);
The alarm is delivered to my receiver at the right time, but is often set to false value from EXTRA_ID
: This is a value I have Used at the point, which wanted to deliver at that particular time, not just that.
documents for pendingIntent .getBroadcast ()
says:
returns
matches existing criteria or returns new pending returns.
The problem is that for this purpose only matches two different intents in Xtra, then You can then retrieve it using an ID number: ... or definitely use additional supplies and that. getBroadcast ()
some random old vertical (a different Instead of a new one around the intent to extract the intent, I have to supply a data Uri to decide and to separate it with the id like:
Intent I = New Intent (MyReceiver.ACTION_ALARM, Uri.parse ("Timer:" + ID));
long.parsleng (intent.getData (.) GetSchemeSpecificPart ());
Comments
Post a Comment