Moto Display中的通知

时间:2016-04-27 12:50:24

标签: android notifications lockscreen

我创建了一个通知,它可以正常工作,但在锁定时不会在Moto Display中显示。 我更改了优先级,类别等没有任何影响。 我希望这个通知像消息或错过的cals: moto display

这是一项服务:

PendingIntent pendingIntent = PendingIntent.getActivity(this, requestCode /* Request code */, intent,
                PendingIntent.FLAG_ONE_SHOT);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.emblem2)
                    .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_help_red))
                    .setColor(getResources().getColor(R.color.colorFirst))
                    .setContentTitle(title)
                    .setContentText(location)
                    .setAutoCancel(true)
                    .setSound(defaultSoundUri)
                    .setShowWhen(true)
                    .setCategory(Notification.CATEGORY_ALARM)
                    .setLights(Color.YELLOW, 200, 200)
                    .setContentIntent(pendingIntent);

   notificationBuilder.setVibrate((sharedPreferences.getBoolean("notifications_new_message_vibrate", false) ? new long[]{0, 300, 200, 300} : new long[]{}));
            NotificationManager notificationManager =
                    (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.notify(requestCode, notificationBuilder.build());

2 个答案:

答案 0 :(得分:0)

正如Marcin所指出的,Moto Display 无法使用通知小图标中的矢量绘图。我遇到了同样的问题,更改小图标解决了这个问题。

令人遗憾的是,Moto Display这样一个不错的功能并没有指出文件。

答案 1 :(得分:0)

Notification notification = new Notification.Builder(context)
    // Show controls on lock screen even when user hides sensitive content.
    .setVisibility(Notification.VISIBILITY_PUBLIC)
    .setSmallIcon(R.drawable.ic_stat_player)
    // Add media control buttons that invoke intents in your media service
    .addAction(R.drawable.ic_prev, "Previous", prevPendingIntent) // #0
    .addAction(R.drawable.ic_pause, "Pause", pausePendingIntent)  // #1
    .addAction(R.drawable.ic_next, "Next", nextPendingIntent)     // #2
    // Apply the media style template
    .setStyle(new Notification.MediaStyle()
    .setShowActionsInCompactView(1 /* #1: pause button */)
    .setMediaSession(mMediaSession.getSessionToken())
    .setContentTitle("Wonderful music")
    .setContentText("My Awesome Band")
    .setLargeIcon(albumArtBitmap)
    .build();

在我的Moto Z中有效,可能只能在媒体模式下工作。