开发者

Will AlarmManager run two instances of the same alarm at once?

I am calling the following code two times in my application. Will Android start a second alarm if one alarm is already running and the code is called again, or will it run only one at a tim开发者_如何学JAVAe?

Intent recurringIntent = new Intent(MY_INTENT);
recurringIntent.setPackage(MY_PACKAGE_NAME);
PendingIntent recurPendingIntent = PendingIntent.getBroadcast(context, 0 /* requestCode */, recurringIntent, 0 /* flags */);
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(), STATS_TIME_INTERVAL, recurPendingIntent);


If you use the same intent and request code to create the PendingIntent, your previous alarm will be overwritten.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜