Java AlarmManager在Android 8.1.0中不工作

Java AlarmManager在Android 8.1.0中不工作,java,android,Java,Android,我的要求设置为通知特定时间,如用户生日或假期 我正在使用使用广播接收器安排通知 代码在6.0中运行良好(即使应用程序被关闭,从最近的列表中删除),但在Android 8.1.0中不起作用(Mf:Oppo) 读了很多答案,但没有找到任何帮助 你知道怎么解决这个问题吗 这是我的密码 AlarmManager am = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); //c

我的要求设置为
通知
特定时间,如用户生日或假期

我正在使用使用广播接收器安排通知

代码在6.0中运行良好(即使应用程序被关闭,从最近的列表中删除),但在Android 8.1.0中不起作用(Mf:Oppo)

读了很多答案,但没有找到任何帮助 你知道怎么解决这个问题吗

这是我的密码

    AlarmManager am = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);

    //creating a new intent specifying the broadcast receiver\

    Intent i = new Intent(this, HolidayBroadcast.class);
    i.putExtra("eventName",islamicHoliday.getEventName());
    i.putExtra("dateH", testTmp.getCalendar().getTimeInMillis());
    i.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
    //creating a pending intent using the intent
    PendingIntent pi = PendingIntent.getBroadcast(this, new Random().nextInt(), i, PendingIntent.FLAG_UPDATE_CURRENT);


    //setting alarm
    if(Build.VERSION.SDK_INT>= Build.VERSION_CODES.M) {
        am.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP,getTimeInMillis(), pi);
    }
    else
    {
        am.setExact(AlarmManager.RTC_WAKEUP, getTimeInMillis(), pi);
    }

您可以使用链接中提到的workmanager。它支持所有api版本,并且易于使用,因为它使用了对api级别14的向后兼容性


请参阅此,你能给我举一些工作调度程序的例子吗?我试过了,但一年后就不再为工作调度程序工作了,但是如果你使用工作管理器,那么就没有必要使用工作调度程序在特定时间执行任务?Workmanager不适用于此(任务可以延迟)