나는 캘린더 이벤트 알림을 작업 중입니다. 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
내 대답을 편집했습니다. – Kanth
당신은 +1 이상의 가치가 있습니다 ... 고마워. –