function addAlarm() {
// --- 注册监听 start ---
var IntentFilter = plus.android.importClass('android.content.IntentFilter');
var filter = new IntentFilter(ALARM_RECEIVER);
main.registerReceiver(receiver, filter);
// --- 注册监听 end ---
// --- 设置闹铃时间 start ---
var Calendar = plus.android.importClass('java.util.Calendar');
var calendar = Calendar.getInstance();
// 11点4分执行
// calendar.set(Calendar.HOUR_OF_DAY, 13);
// calendar.set(Calendar.MINUTE, 41);
// calendar.set(Calendar.SECOND, 0);
// 过5s 执行
calendar.setTimeInMillis(Date.parse(new Date()));
calendar.add(Calendar.SECOND, 5);
// --- 设置闹铃时间 end ---
// --- 设置闹铃 ---
var Intent = plus.android.importClass('android.content.Intent');
var intent = new Intent(ALARM_RECEIVER);
//
// var PendingIntent = plus.android.importClass('android.app.PendingIntent');
//var sender = PendingIntent.getBroadcast(main, 0, intent, 0);
var PendingIntent = plus.android.importClass('android.app.PendingIntent');
var sender=PendingIntent.getService(main, 0, intent, 0);
var AlarmManager = plus.android.importClass("android.app.AlarmManager");
var Context = plus.android.importClass("android.content.Context");
var alarm = main.getSystemService(Context.ALARM_SERVICE);
// 一次
alarm.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);
// 重复多次
//alarm.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 5 * 1000, sender);
mui.toast("设置闹铃5秒后提醒: "+getCurTime());
};