Setting an alarm cancels any previous alarms that have the same intent
as the new one.
In your code, the old and new intents only differ by their extras, which
are not considered (I believe).
What you could do is calculate the next point in time when an alarm is
needed, set one alarm, and when it goes off, figure out which of the
possible actions you need to perform.
-- Kostya
16.08.2010 11:49, nomi пишет:
Hi all,
In my application i have created pending intent which calls another
activity (after 20mins of alarm off) with the help of alarm manger. It
should happen each time for each new pending intent or when I call
that activity.
But when i create one pending intent and after few mins again create
new pending intent ,then the last one overlap the other previous
pending intents and start specified activity only for ones for the
last pending intent.
I want that each time i create any pending intent it should start
specified activity after 20 mins of it's alarm off time.How it can be
done ?
here is my code:--
Intent intent = new Intent(getApplicationContext(),AlarmCall.class);
intent.putExtra("PolicyNo3",policyNo2);
intent.putExtra("BarcodeNo",barcode_no);
Constants.pendingResultList.put(policyNo2, barcode_no);
System.out.println(Constants.pendingResultList.containsKey(policyNo2));
PendingIntent pendingIntent =
PendingIntent.getBroadcast(getApplicationContext(),
0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager =
(AlarmManager)
getSystemService(ALARM_SERVICE);
long timedely = System.currentTimeMillis() +
(20*60*1000);
alarmManager.set(AlarmManager.RTC_WAKEUP,timedely,
pendingIntent);
////// Below is the code of ALarmCall.class
manger = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new
Notification(R.drawable.icon,"Please upload
result",System.currentTimeMillis());
Intent startActivity1 = new Intent();
startActivity1.setClass(context, UploadTest.class);
startActivity1.setAction(UploadTest.class.getName());
startActivity1.putExtra( "PolicyNo4",policyNo3);
startActivity1.putExtra("BarcodeNo1",barcodeNo);
startActivity1.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
PendingIntent contentIntent =
PendingIntent.getActivity(context,
0,startActivity1 ,Intent.FLAG_ACTIVITY_NEW_TASK);
notification.setLatestEventInfo(context, "HIV
Pharmacy","Result of
Id- "+policyNo3,contentIntent);
notification.flags = Notification.FLAG_ONLY_ALERT_ONCE |
Notification.FLAG_SHOW_LIGHTS;
notification.ledARGB = Color.GREEN;
notification.ledOnMS = 1000;
notification.ledOffMS = 500;
notification.defaults = Notification.DEFAULT_SOUND |
Notification.DEFAULT_VIBRATE;
manger.notify(32, notification);
context.startActivity(startActivity1);
Thanks to all.
--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en