alarmmanager.setrepeating在一段时间后停止工作

holgip5t  于 2021-07-08  发布在  Java
关注(0)|答案(0)|浏览(203)

下面是我的代码,它在最初的7天左右工作得很好,但之后就停止了。我不知道为什么?
我和这个人有很多相同的问题:这里
任何帮助都将不胜感激:)

Intent _intent = new Intent(context, AlarmBroadcastReceiver.class);

    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, _intent, PendingIntent.FLAG_UPDATE_CURRENT);
    AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
    alarmManager.cancel(pendingIntent);

    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    calendar.set(Calendar.HOUR_OF_DAY, hour);
    calendar.set(Calendar.MINUTE, min);
    calendar.set(Calendar.SECOND, sec);
    // every 24 hours (daily) at the time set
    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 1000 * 60 * minTime * MainSetTimeInt, pendingIntent);

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题