Moto Display中的通知

问题描述:

我创建了一个通知,它可以工作,但锁定时不会显示在Moto Display中。 我改变了优先级,类别等没有影响。 我想这个通知类似消息或错过CALS: moto displayMoto 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()); 
+0

可能是你的应用程序被锁定,虽然检查你的设置**声音和通知**找到**当设备被锁定**。 –

+0

我检查了,我已启用,所有应用程序都会显示,除了我的,甚至是已签名的应用程序,也许它必须从Google Play收到? – Marcin

+0

的详细文档去[这里](http://developer.android.com/guide/topics/ui/notifiers/notifications.html)可能是你错过了一些东西。 –

正如马尔辛指出,摩托显示不通知小图标与矢量绘制工作。我遇到了同样的问题,更改小图标解决了问题。

很遗憾,Moto Display这样一个不错的功能没有文档指出。

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中工作,也许只能在媒体模式下工作。