AlarmManager无法处理App Upgrade

时间:2014-04-25 05:35:36

标签: android alarmmanager android-pendingintent

在我之前的版本中,我每15分钟安排一次警报,并且它正常工作,给出了logs.I设置重复警报。

这是代码

AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Intent healthSender = new Intent(context, XYZ.class);
    healthSender.setAction("com........sendhealth");
    PendingIntent pi = PendingIntent.getService(context, 0, healthSender, PendingIntent.FLAG_UPDATE_CURRENT);
    mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), 15*60000,pi);

稍后在新版本中,..

我必须更改警报并在特定时间的特定时间触发..

我将警报从重复改为一般时间。

我跟着,在下次触发后接近调度警报。

这是代码..

PendingIntent pi = PendingIntent.getService(context, 0, healthSender, PendingIntent.FLAG_UPDATE_CURRENT);
            mgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + getTimeForNextHealthAlarm(), pi);
            System.out.println("////   Setting NEW ALARM ///////");
            Log.d("UtilAlarmSetter", "Alarm Set");

getTimeForNextHealthAlarm()  ==> gives times for this alarm.

它在我的机器上工作正常,但在谷歌播放时更新..

在新版本中有两种情况 1)新警报根本不起作用 2)在某些情况下,之前15分钟的警报仍在发射

我该如何调试此问题。就像在我的机器上一切正常。 当我从谷歌播放中卸载并下载新鲜的应用程序时,此警报未触发,但是当我从我的机器上的代码执行此操作时,一切正常。

注意: - 两个版本中待处理意图的RequestId相同

Q-更新版本应该在再次安排之前先取消警报吗? 是否可以在谷歌播放更新应用程序时,此警报配置不正确?? **

任何帮助将不胜感激 感谢

0 个答案:

没有答案