J'ai du code qui crée des notifications, c'est vraiment basique.
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);
3 Réponses :
Vous ne pouvez pas glisser votre notification, car il se trouve dans un "en cours" -state.
Remplacer les indicateurs de réglage avec le code suivant : P> notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
C'était exactement ce que j'avais besoin de savoir. Merci!
Commencé Shwoing avec Setongoing (Faux) et Notification.Flags | = Notification.Flag_auto_Cancel.
Il suffit d'insérer cette ligne lorsque vous faites la notification ...
// Will show lights and make the notification disappear when the presses it notification.flags == Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS;
Vous devez utiliser Setongoing (booléen en cours) strong> Définir s'il s'agit d'une notification "en cours". Notifications en cours
ne peut pas être rejeté par l'utilisateur, de sorte que votre application ou votre service doit
prenez soin de les annuler. Ils sont généralement utilisés pour indiquer un
Tâche de base que l'utilisateur est activement engagé avec (par exemple.
musique) ou est en attente d'une manière ou d'une autre et occupe donc l'appareil
(E.G., un téléchargement de fichier, une opération de synchronisation, une connexion réseau active). P>
blockQuote> Vous pouvez utiliser p>
Essayez de supprimer Flag_auto_Cancel
MH ... Essayez d'attribuer le premier drapeau à NtOfication.Flags et non au bit dans le sens ou au premier drapeau. Modifier la notification.Flags | = Default_sound to notification.Flags = Notification.default_sound; Peut-être que cela aidera
Cela semble être un problème vraiment étrange. Désolé, je pense que je ne peux pas vous aider à le résoudre :(