我将重复闹钟设置为每2分钟触发一次,而是每5分钟触发一次。我在5分钟内测试了不同的间隔,但这种行为没有改变。是否有最低限度的Android强制执行?我正在使用4.1.2。这是我的代码
Intent intent = new Intent(context, UpdateAlarmReceiver.class);
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 0, 120000, alarmIntent);
答案 0 :(得分:1)
我修复了添加WakeLock的问题:
framework:
validation: { enabled: true, enable_annotations: false }
您还应该向Manifest添加权限:
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
WakeLoc wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakelock");
wakeLock.acquire(180000); //Auto-close in three minutes