android:在特定时间显示通知?

android:在特定时间显示通知?,android,time,notifications,Android,Time,Notifications,我有一个名为show\u notification()的函数,当用户点击按钮时我会调用该函数。关键是,我希望在特定的time=hours:mins 其中,小时和分钟是两个整数,其值为我想要的时间[例如,小时=22,分钟=40..表示在22:40[10:40 pm]发出此通知]。顺便说一下,这个警报应该每天同时重复 public void show_notification() { CharSequence notify_msg="Don't foget!"; Ch

我有一个名为
show\u notification()
的函数,当用户点击按钮时我会调用该函数。关键是,我希望在特定的
time=hours:mins

其中,小时和分钟是两个整数,其值为我想要的时间[例如,小时=22,分钟=40..表示在22:40[10:40 pm]发出此通知]。顺便说一下,这个警报应该每天同时重复

public void show_notification() {
        CharSequence notify_msg="Don't foget!";
        CharSequence title= "you ve been notified by My app";
        CharSequence details= "It works!";
        NotificationManager nm= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notify= new Notification(android.R.drawable.stat_notify_more,
                                notify_msg, 
                                System.currentTimeMillis());
        Context mycontext= ActA.this;
        Intent myintent= new Intent (mycontext, ActA.class);
        PendingIntent pending= PendingIntent.getActivity(mycontext, 0, myintent, 0); ///0's are not applicable here
        notify.setLatestEventInfo(mycontext, title, details, pending);

        nm.notify(0, notify);



    }

我希望您能详细回答,因为我是一名非常新的开发人员。

这很简单。您可以使用报警管理器。您可能需要修改清单文件并注册应用程序,以便从alarmmanager获取通知。现在,您可以要求alarm manager类在您的应用程序将收到的所需时间发送消息


您必须以响应此消息并向用户显示通知的方式对活动进行编程。

-您可以用通知代替toast。本页上还有几个有趣的示例,说明您可以使用alarm manager执行的有趣操作。