Ich versuche, eine Benachrichtigung über Android Auto anzuzeigen. Die Benachrichtigung zeigt auf meinem Telefon. Es ist jedoch nicht zeigt auf Android Auto-Emulator. Dies ist eine Medienanwendung.Android Auto-Benachrichtigung wird nicht angezeigt
automotvie_app_desc.xml:
<automotiveApp>
<uses name="media"/>
</automotiveApp>
Dieser Code ist in meiner MediaBrowserService
Klasse:
private Notification postNotification(AutoNotificationHelper.Type type) {
Log.d(TAG, "Post Notification");
Notification notification = AutoNotificationHelper.createMenuErrorNotification(
getApplicationContext(), type, mSession);
if (notification != null) {
mNotificationManager.notify(TAG, NOTIFICATION_ID, notification);
}
return notification;
}
Hier ist, wo die Meldung erstellt:
static Notification createMenuErrorNotification(Context context, Type type,
MediaSessionCompat mediaSession) {
MediaControllerCompat controller = mediaSession.getController();
MediaMetadataCompat mMetadata = controller.getMetadata();
PlaybackStateCompat mPlaybackState = controller.getPlaybackState();
if (mMetadata == null) {
Log.e(TAG, "MetaData is null");
}
if (mPlaybackState == null) {
Log.e(TAG, "Playback state is null");
}
if (type.equals(Type.MENU_ERROR)) {
Bitmap icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.error);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context.getApplicationContext());
notificationBuilder.extend(new android.support.v4.app.NotificationCompat.CarExtender())
.setStyle(new NotificationCompat.MediaStyle()
.setMediaSession(mediaSession.getSessionToken()))
.setSmallIcon(R.drawable.error)
.setShowWhen(false)
.setContentTitle(context.getString(R.string.title))
.setContentText(context.getString(R.string.message))
.setLargeIcon(icon)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
return notificationBuilder.build();
}
return null;
}
Was bin ich Holen Sie dies auf der Auto-Display und nicht auf dem Handy anzeigen?
Dies zeigt immer noch nur die Benachrichtigung auf dem Telefon und nicht auf der Auto-Head-Unit. – mattfred