AlarmManager 运行 在模拟器中一天中的特定时间

AlarmManager run at specific time of the day in emulator

如果我设置 HOUR=11 和 MINUTE=00,它不会在我的模拟器中 11:00 时间 运行,这里有什么问题吗?:

Calendar cal = Calendar.getInstance();
PendingIntent pintent = PendingIntent.getService(this, 0, new Intent(this, MyService.class), 0);
cal.set(Calendar.MINUTE, MINUTE);
cal.set(Calendar.HOUR_OF_DAY, HOUR);
cal.add(Calendar.DAY_OF_YEAR,1);
AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 86400000, pintent);
running = true;

这个闹钟会起作用11:00am..

    Calendar cal = Calendar.getInstance();
    Intent intent = new Intent(this,  MyService.class);
    PendingIntent penintent = PendingIntent.getService(this, 0, intent, 0);
    AlarmManager alarm = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);

      //Here I have set it to 11.00am

         Calendar cal = Calendar.getInstance();
         cal.set(Calendar.HOUR_OF_DAY, 11);
         cal.set(Calendar.MINUTE, 0);
         cal.set(Calendar.SECOND, 0);

        //set timer as a RTC Wakeup to alarm manager object
     alarm.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY, penintent);

我建议,尝试使用此解决方案。