由网友(夏了夏天蓝了海)分享简介:在我的Android应用程序,我想在特定的时间由用户输入一些消息的时间设置报警。我如何使用广播接收器设置报警?是否有可能弹出一个消息比默认的消息?其他指定的时间解决方案 AlarmManager ALR =(AlarmManager)this.getSystemService(ALARM_SERVICE);意向...
在我的Android应用程序,我想在特定的时间由用户输入一些消息的时间设置报警。
我如何使用广播接收器设置报警?是否有可能弹出一个消息比默认的消息?
其他指定的时间解决方案 AlarmManager ALR =(AlarmManager)this.getSystemService(ALARM_SERVICE);意向意图=新意图(YourAction);的PendingIntent的PendingIntent = PendingIntent.getBroadcast(背景下,0 / ** SOM唯一的ID * /,意向,0);alr.set(AlarmManager.ELAPSED_REALTIME,0 / **这里是一个延迟* /的PendingIntent);
之后,你应该创建一个广播接收器
,将获得与行动=YourAction
意图。从接收器就可以启动,这将shoiw您与您的自定义消息对话框的活动。见this答案,看看如何设置的广播接收器。
In my Android application I would like to set alarm at a particular time with some message for time entered by user.
How can I set alarm using broadcast receiver? Is it possible to pop up a message on the specified time other than the default message?
解决方案AlarmManager alr = (AlarmManager) this.getSystemService(ALARM_SERVICE);
Intent intent = new Intent("YourAction");
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0/** som unique id*/, intent, 0);
alr.set(AlarmManager.ELAPSED_REALTIME, 0/** here is a delay*/, pendingIntent);
after that you should create a BroadcastReceiver
, that will get intent with action = "YourAction"
. From that receiver you can start an activity which will shoiw you the dialog with your custom messages. See this answer to see how to setup the BroadcastReceiver.
相关推荐
最新文章