androidandroid-notificationsandroid-auto

Show notification only on Android Auto, not on the mobile


Can I somehow show the notification only on Android Auto?

What I am using:

//create channel
private val channel = NotificationChannel(channelId, channelName, 
NotificationManager.IMPORTANCE_NONE)

...

//Show the notification
val builder = NotificationCompat.Builder(carContext, channelId)
        .setSmallIcon(iconId)
        .setContentTitle(getString(contentStringId))
//Extend for Android Auto
        .extend(
            CarAppExtender.Builder()
                .setSmallIcon(iconId)
                .setContentTitle(getString(contentStringId))
                .setImportance(NotificationManagerCompat.IMPORTANCE_HIGH)
                .build()

        )

    with(NotificationManagerCompat.from(carContext)) {
        notify(MapConstants.NOTIFICATION_ID_ALERT, builder.build())
    }

I have also tried 2 different channels - 1 with NONE importance, another with HIGH, but whatever I try - the notification is neither shown on mobile nor on auto if the original channel importance is set to NONE

Just to clarify - if I set initial channel importance to HIGH it shows on both - mobile and auto


Solution

  • This is not currently supported on Android Auto - I'd recommend making a feature request at https://issuetracker.google.com/issues/new?component=460472&template=1554359