public class SchedulerSetupReceiver extends WakefulBroadcastReceiver {
private static final String APP_TAG = "com.hascode.android";
private static final int EXEC_INTERVAL = 10 * 1000;
DBhelper dbhelper;
@Override
public void onReceive(final Context ctx, Intent intent) {
Log.d(APP_TAG, "SchedulerSetupReceiver.onReceive() called");
dbhelper = new DBhelper(ctx);
String[] ID = dbhelper.FetchAllID();
String[] time = dbhelper.FetchAlltime();
ArrayList<PendingIntent> intentArray = new ArrayList<PendingIntent>();
AlarmManager alarmManager = (AlarmManager) ctx
.getSystemService(Context.ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.set(calendar.HOUR_OF_DAY, 16);
calendar.set(calendar.MINUTE, 22);
calendar.set(calendar.SECOND, 0);
calendar.set(calendar.MILLISECOND, 0);
long sdl = calendar.getTimeInMillis();
for (int k = 0; k < ID.length; k++) {
intent = new Intent(ctx, SchedulerEventReceiver.class);
// Loop counter `i` is used as a `requestCode`
PendingIntent pendingIntent = PendingIntent.getBroadcast(ctx, k,
intent, 0);
// Single alarms in 1, 2, ..., 10 minutes (in `i` minutes)
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, sdl,
pendingIntent);
intentArray.add(pendingIntent);
}
}
这是我的警报代码我想为特定时间设置闹钟但是当时间已经完成时它不会触发我已经使用日历而我已经设置为4:20分钟Pm因为我已经在16小时和分钟中添加20但是当设备时间达到4.20 Pm时它没有被触发请告诉我我做错了什么
答案 0 :(得分:1)
试试这个
"highlight" : [
{
"status" : "upcoming",
"limit":"10"
},
{
"status" : "overdue",
"limit":"1"`
},
{
"status" : "today",
"limit":"3"
}
]
答案 1 :(得分:1)
确保您已在Manifest中注册了广播接收器。
<receiver android:name=".SchedulerEventReceiver"/>
并提供警报许可。
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
答案 2 :(得分:0)
我想你忘记告诉日历今天是星期几。
calendar.setTimeInMillis(System.currentTimeMillis());