Se avuto alcuni problemi con una notifica voglio mostrare nella barra di notifica. Sebbene abbia impostato il flag di notifica su Notification.DEFAULT_LIGHTS & Notification.FLAG_AUTO_CANCEL
, la notifica non scompare dopo aver fatto clic su di essa. Qualche idea su cosa sto facendo male?notifica Android non scompare dopo aver cliccato il notifica
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
int icon = R.drawable.icon;
CharSequence tickerText = "Ticker Text";
long time = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, time);
notification.flags = Notification.DEFAULT_LIGHTS & Notification.FLAG_AUTO_CANCEL;
Context context = getApplicationContext();
CharSequence contentTitle = "Title";
CharSequence contentText = "Text";
Intent notificationIntent = new Intent(this, SilentFlipConfiguration.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(1,notification);
Grazie mille. Ha funzionato per me – Sakthimuthiah
Quindi, quali differenze creano notifiche usando Notification 'mNotificationManager.notify (1, notification);' e usando NotificationBuilder 'mNotificationManager.notify (1, mBuilder.build());'? Grazie. – NPE
Questa risposta dovrebbe essere accettata, è più in linea con la dottrina corrente di progettazione Android – jmaculate