lundi 29 décembre 2014

Is there a way to make NotificationListenerService get notifications first?

I have a NotifcationListenerService that is receiving notifications, but in some cases, I want my app to be able to prevent the notification from making the default sound. For example, with SMS messages, I'd like to prevent the SMS notification from making the default noise, but only if I've handled the notification (I'm reading the notifications using TextToSpeech).


I know I can use cancelNotification(), but sometimes the notification gets posted to the notification bar (and thus the notification sound is played) before I can cancel it. Is there a way to set the priority of this listener?


Alternatively, I've created a BroadcastReceiver to listen for SMS_RECEIVED intents, but I can't seem to find a way to prevent JUST SMS notifications from making a sound. I can prevent ALL notifications from making a sound, but this isn't exactly what I want, since I'm not handling all notifications, and I don't want the user not to be notified for an event I haven't handled.


Aucun commentaire:

Enregistrer un commentaire