Friday, May 4, 2012

[android-developers] Delay in the Alarms given by multiple instances of AlarmManagers .

I have scheduled multiple alarm managers to send intents at different
times. I took care to pass unique ID, context and extras to both the
pending intents. below func handles the alarm calls. .

public void handle(int duration, int id){
Intent intent = new Intent("package.SET");
intent.putExtra ("package.id", Id);
AlarmManager amg =
(AlarmManager)Context.getSystemService(Context.ALARM_SERVICE);
PendingIntent pis = PendingIntent.getBroadcast(Context,Id,
intent, FLAG_ONE_SHOT);
amg.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
+ time, pis); }

There are 2 functions calling the alarm

public void callalarm(int time){
handle(time, UNIQUE_ID1);}

and

public void callalarm2(int time){
handle(time, UNIQUE_ID2);}

I took care that unique ID1 and Unique_ID2 are different. The
broadcast receiver handles the alarm and executes another code. Is
there a possibility that Callalarm1 and callalarm2 interfere with
eachother .

I have registered the receiver using registerReceiver function and not
in android manifest file.

IntentFilter ARFilter = new IntentFilter();
ARFilter.addAction("package.SET");
context.registerReceiver(AR, ARFilter);

In the AR that extends broadcast receiver, i use the id to define the
action.
The problem is that, I get a delay in the alarms called. Is there a
reason why there is a delay ?

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment