【发布时间】:2011-04-18 19:10:26
【问题描述】:
我正在跳槽(当然,这并不复杂)以避免两次启动警报。基本代码如下:
AlarmManager mgr=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent i=new Intent(this, MyService.class);
PendingIntent pi=PendingIntent.getService(this, 0, i, 0);
mgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), AlarmManager.INTERVAL_FIFTEEN_MINUTES, pi);
如果我每次启动应用程序时都运行这段代码,这有什么关系吗?在将其称为过度杀伤实验大约 10 次时,我没有看到任何不良影响,但我找不到任何关于这是巧合还是预期行为的参考。
如果不是特别期待,那感觉“不对”。如果AlarmManager 的行为发生变化,以后可能会给我带来麻烦。
【问题讨论】:
标签: android alarmmanager