7
我正在处理Calender事件提醒。在Android中没有本机日历事件提醒,因此用户可以安装不同的日历应用程序。使用PendingIntent显示对话框
现在这些应用程序可以不同的提醒事件,如提醒通知可以显示。现在我希望我在这些事件日历应用中以编程方式设置事件,并且及时达到不显示任何通知,而弹出消息将显示带声音的警报。在那我使用该网站的代码。它的工作,但它显示通知形式的提醒。
这里是代码:
的onReceive
void doReminderWork(Intent intent) {
Long rowId = intent.getExtras().getLong(RemindersDbAdapter.KEY_ROWID);
NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(this, ReminderEditActivity.class);
notificationIntent.putExtra(RemindersDbAdapter.KEY_ROWID, rowId);
PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT);
Notification note=new Notification(android.R.drawable.stat_sys_warning, getString(R.string.notify_new_task_message), System.currentTimeMillis());
note.setLatestEventInfo(this, getString(R.string.notify_new_task_title), getString(R.string.notify_new_task_message), pi);
note.defaults |= Notification.DEFAULT_SOUND;
note.flags |= Notification.FLAG_AUTO_CANCEL;
int id = (int)((long)rowId);
mgr.notify(id, note);
}
现在我要显示一个对话框,而不是通知,以便它如何能够使用这些代码,这个悬而未决的意图,应使用在对话框中。
Intent notificationIntent = new Intent(this, ReminderEditActivity.class);
notificationIntent.putExtra(RemindersDbAdapter.KEY_ROWID, rowId);
PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT);
感谢您的帮助。如果我想在对话框显示时显示声音 – User42590 2013-04-08 08:49:14
编辑我的答案。 – Kanth 2013-04-08 08:58:08
你值得拥有超过+1 ...谢谢。 – 2015-05-06 17:12:51