单个警报管理器能否以 2 个不同的时间间隔触发,例如第一个间隔应该是 1 分钟,第二个间隔应该是 2 分钟
我正在尝试使用以下代码,但它没有像我预期的那样工作:(
{
AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmManagerBroadcastReceiver.class);
intent.putExtra(ONE_TIME, Boolean.FALSE);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);
am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000 * 60 *x, pi);
}
//Initialized x=1;
//In onReceive what i did was...
public void onReceive(Context context, Intent intent) {
if(x===1)
x=2;
else
x=1;
}
这是错的吗?