당신은 당신의 훌륭한 대답이
NotificationManager mNotificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
Notification notification = null;
Intent intent = new Intent(context, PdfDialogAlert.class);
intent.putExtra("dialog", 1);
PendingIntent piDismiss =
PendingIntent.getActivity(context, 0, intent, 0);
builder.setContentIntent(piDismiss)
.setSmallIcon(R.drawable.ic_notif)
.setWhen(System.currentTimeMillis())
.setContentTitle("fileName")
.setTicker(message)
.setContentText("message");
notification = builder.build();
notification.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL;
감사처럼 많은 일을 할 수 있습니다. 이제 클릭 한 상태 표시 줄에서 알림을 제거하는 방법이 하나뿐입니다. 사실이 코드를 추가했습니다 "mBuilder.setAutoCancel (true);" 그러나 작동하지 않습니다. – Gilana
위의 코드에서 FLAG_AUTO_CANCEL은 다음을 참조 할 것입니다. http://developer.android.com/reference/android/app/Notification.html#FLAG_AUTO_CANCEL – keshav
안녕하세요, 코드에 버그가 있습니다. 새로운 사용자 계정을 만들 때마다 우리는 항상 이클립스에서 두 번 응용 프로그램을 실행하여 알림을 표시 할 수 있습니다. 이 문제에 대해 알고 있습니까? – Gilana