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