使用AlarmManager发送的通知的时间安排不正确

问题描述

我想使用警报管理器发送通知,因为通知必须准确且离线发送。

所以我尝试了setExact方法,但是如果我将时间设置为仅说6:05 PM,那么通知将直接发送。如果设置了警报管理器(如用户在5:30设置为警报),它将在6:30发送通知

我想使用集合重复,但是不准确。请帮助我,我在此错误上停留了3个月。

我要实现的目标是每天在特定时间离线发送通知,而不会出现任何错误。请帮我 谢谢

我的收件者-

 Toast.makeText(context,"In receiver",Toast.LENGTH_SHORT).show();

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context,"Habit")
            .setContentText(intent.getStringExtra("name"))
            .setContentTitle("Have you done this habit?")
            .setSmallIcon(R.drawable.ic_launcher_foreground)
            .setSound(ringtoneManager.getDefaultUri(ringtoneManager.TYPE_NOTIFICATION))
            .setPriority(NotificationCompat.PRIORITY_HIGH);

    notificationmanagerCompat nmc = notificationmanagerCompat.from(context);

    nmc.notify(100,builder.build());

我的警报管理器

Toast.makeText(getContext(),"API level " + Build.VERSION.SDK_INT,Toast.LENGTH_SHORT).show();
    Intent intent = new Intent(getContext(),Receiver.class);
    intent.putExtra("name",getActivity().getIntent().getStringExtra("HNAME2"));
    PendingIntent pendingIntent = PendingIntent.getbroadcast(getContext(),intent,0);
    AlarmManager am = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
    am.set(AlarmManager.RTC_WAKEUP,c.getTimeInMillis(),pendingIntent);

我的清单-

<receiver android:name=".broadcasts.Receiver" />

我该如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)