I am trying to build an app which will show notifications in a different UI. I can use NotificationListenerService to get updates on notifications. Recently Android added support for Android Auto. Which gives more capability like replyIntent etc. How can I read this information from StatusBarNotification
Asked
Active
Viewed 247 times
0
-
Are you trying to gather notifications from all other apps, and group them into a different UI? Is that why you want the replyIntent, to be able to respond to other apps notifications from that different UI? – salminnella Nov 06 '18 at 21:09
-
I am trying to build an alternative for Android Auto. I need to know If I can access the CarExtender information from Notification Object – bhkiran Nov 12 '18 at 14:14
1 Answers
0
You can get the CarExtenders UnreadConversation from sbn.getNotification().
public class NotificationListener extends NotificationListenerService {
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
super.onNotificationPosted(sbn);
processNotifications(sbn);
}
private void processNotifications(StatusBarNotification sbn) {
// get the CarExtender from the sbn
CarExtender carExtender = new CarExtender(sbn.getNotification());
//get the unread conversation from the carExtender
UnreadConversation unreadConversation = carExtender.getUnreadConversation();
// get the remote input and read/reply pending intents
if (unreadConversation != null) {
RemoteInput remoteInput = unreadConversation.getRemoteInput();
PendingIntent readPendingIntent = unreadConversation.getReadPendingIntent();
PendingIntent replyPendingIntent = unreadConversation.getReplyPendingIntent();
}
}
}
A couple of things to be aware of is that Android Auto is also using a NotificationListenerService, and all notifications listeners are informed about new notifications at the same time. There's no time for one listener to prevent others from displaying the notification, nor is there a way for one listener to take priority over another.
Also, using the Public SDK for Auto, there isn’t any availability to actually draw elements to the screen that is projected to the Head Unit. It sounds like you might be trying to do this when you mention “show notifications in a different UI”

salminnella
- 744
- 2
- 6
- 17