I followed the tutorial on Udacity and the developer site for Android auto. I am using a DVU for testing. The notifications don't show up on the DHU but appears on the phone here is my code:
Using GcmListenerService:
final PendingIntent contentIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT
| PendingIntent.FLAG_ONE_SHOT);
final PendingIntent contentIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT
| PendingIntent.FLAG_ONE_SHOT);
Intent msgHeardIntent = new Intent()
.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
.setAction("com.xyz.abc.MY_ACTION_MESSAGE_HEARD")
.putExtra("conversation_id", 9999);
PendingIntent msgHeardPendingIntent =
PendingIntent.getBroadcast(getApplicationContext(),
9999,
msgHeardIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.CarExtender.UnreadConversation.Builder unreadConvBuilder =
new NotificationCompat.CarExtender.UnreadConversation.Builder("TestAndroidAuto")
.setReadPendingIntent(msgHeardPendingIntent);
unreadConvBuilder.addMessage(description);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setSmallIcon(R.drawable.ic_stat_notification_icon)
.setContentTitle(title)
.setTicker(ticker)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(description))
.setContentText(description)
.setDefaults(Notification.DEFAULT_ALL);
mBuilder.extend(new NotificationCompat.CarExtender().setUnreadConversation(unreadConvBuilder.build()));
mBuilder.setContentIntent(contentIntent);
mBuilder.setAutoCancel(true);
mNotificationManager = NotificationManagerCompat.from(getApplicationContext());
mNotificationManager.notify(REMOTE_NOTIFICATION_ID, mBuilder.build());
I could not understand where I am going wrong as this is fairly new.