在我的Android应用程序中,我想设置闹钟在一个特定的时间与一些消息的时间输入的用户。
如何使用广播接收器设置闹钟?是否可以在指定时间弹出默认消息以外的消息?
发布于 2010-12-16 21:28:50
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);在此之后,您应该创建一个BroadcastReceiver,这将获得action = "YourAction"的意图。从该接收方,您可以启动一个活动,该活动将向您提供自定义消息的对话框。要了解如何设置BroadcastReceiver,请参阅this answer。
https://stackoverflow.com/questions/4461147
复制相似问题