Ich habe einige Code, der einige Benachrichtigungen erstellt, ist es wirklich einfach.Android 4: kann keine Benachrichtigung durch Wischen
int icon = R.drawable.notification;
CharSequence tickerText = "Text";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = "Text";
CharSequence contentText = "Text";
Intent notificationIntent = new Intent(this, RequestActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.flags |= Notification.DEFAULT_SOUND;
notification.flags |= Notification.DEFAULT_VIBRATE;
notification.flags |= Notification.DEFAULT_LIGHTS;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(notificationID, notification);
Es funktioniert alles gut in 2.1. In 4.0, alles funktioniert gut, außer die Swipe-to-entlassen Aktion funktioniert nicht. Die Benachrichtigung geht leicht zur Seite, klebt dann und springt zurück. Irgendeine Idee? Danke.
Versuch FLAG_AUTO_CANCEL zu entfernen –
@Copa bereits versucht – James
mh ... versuchen, das erste Flag ntofication.flags zuzuordnen und nicht oder das erste Flag auf bitweise. Ändern Sie notification.flags | = DEFAULT_SOUND in notification.flags = Notification.DEFAULT_SOUND; Vielleicht hilft das –