Android alarmmanager触发未按时完成的意图

Android alarmmanager触发未按时完成的意图,android,android-intent,alarmmanager,Android,Android Intent,Alarmmanager,我正在开发一个android项目,它只想每天在特定的时间发出警报。为此,我在一个服务中使用alarmmanger。我将挂起的意图添加到AlarmManager,并按如下方式设置时间: Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, h); calen

我正在开发一个android项目,它只想每天在特定的时间发出警报。为此,我在一个服务中使用alarmmanger。我将挂起的意图添加到AlarmManager,并按如下方式设置时间:

    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    calendar.set(Calendar.HOUR_OF_DAY, h);
    calendar.set(Calendar.MINUTE, m);

    Intent i = new Intent(DefaultActivity.fullname(Actions.TIME_CHANGED));

    i.putExtra(TIME_NAME, name);
    i.putExtra(TIME_CLOCK, clock);


    PendingIntent pendingIntent = PendingIntent.getService(ctx, index, i, PendingIntent.FLAG_UPDATE_CURRENT);

    AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    alarmManager.setRepeating(AlarmManager.RTC, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent); 
问题是,每当我给我的服务打电话时,我都会收到“动作。时间变了”

我的startCommand是这样的:

@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
String intentAction = intent == null ? null : intent.getAction();

if (intentAction != null)
{
    Log.e(MainActivity.WATERMELON_TAG, "action: " + intentAction);

    if (intentAction.equals(DefaultActivity.fullname(Actions.TIME_CHANGED)))
    {
        clockIsChanged(intent);
    }

    if (intentAction.equals(DefaultActivity.fullname(Actions.TIME_RENEW_CHECKING)))
    {
        reNew();
    }

    if (intentAction.equals(DefaultActivity.fullname(Actions.FIRST_TIME_BOOT)))
    {
        reNew();
    }
}

return START_STICKY;
}
我不知道是什么问题。我的解决方案是,我添加了一个函数来检查挂起时间是否等于当前执行任务的时间,但这不是一个好的解决方案

为什么会这样


提前感谢

文档中说:

注:自API 19起,所有重复报警均不准确

因此,如果您使用的API高于19,则最好使用
AlarmManager.setExact
并在
onReceive
-方法中重新设置警报


另一个可能性是使用低于19的API级别。

共享转储有错误操作。TIME\u Changed我看到它的早期问题也在今天的。。。。。。。建议在我像开发人员站点一样实现我的代码时查看RTC示例!但我不知道为什么每次都是我的意图?但为什么他们每次都打电话来?