2013年8月17日星期六

Help, Android plurality of timing tasks

I would like to start multiple timed inside Android service tasks, each interval is different, but the AlarmManager can only specify a timed task, would like to ask how to solve, or what alternatives do, RequestCode set to different values seems useless, the following is the code
AlarmManager alarmManager = (AlarmManager) getSystemService (this.ALARM_SERVICE);
Intent sendIntent = new Intent (MapService.this, SendReceive.class);
PendingIntent pendingSendIntent = PendingIntent.getBroadcast (this, 111111, sendIntent, 0);
alarmManager.setRepeating (AlarmManager.RTC, System.currentTimeMillis (), ConfigManager.SendInterval * 60 * 1000, pendingSendIntent);
/ /

Intent recvIntent = new Intent (this, RecvReceive.class);
PendingIntent pendingRecvIntent = PendingIntent.getBroadcast (this, 222222, recvIntent, 0);
alarmManager.setRepeating (AlarmManager.RTC, System.currentTimeMillis (), ConfigManager.RecvInterval * 60 * 1000, pendingRecvIntent);

Intent queryIntent = new Intent (this, StateReceive.class);
PendingIntent pendingQueryIntent = PendingIntent.getBroadcast (this, 333333, queryIntent, 0);
alarmManager.setRepeating (AlarmManager.ELAPSED_REALTIME_WAKEUP, 0, ConfigManager.QueryInterval * 60 * 1000, pendingRecvIntent);
------ Solution --------- -----------------------------------
only specify a timed task, too pulled.
PendingIntent.getBroadcast (this, 222222, recvIntent, 0);
second parameter is used to distinguish between different timing tasks.
------ For reference only -------------------------------------- -
I tried useless ah, only the first one is triggered, the solution
------ For reference only ------------------- --------------------
Oh, just carefully read it again, that I was wrong
------ For reference only ---------------------------------------
where wrong, solving

没有评论:

发表评论