5

ElizaChat の例に基づいて行った背景を表示することはできませんが、常に黒の背景を表示することはできません。

これが私のコードです:

public static void createNotification(Context context) {
    int notificationId = 1;

    NotificationCompat.BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
    bigStyle.bigText("I am a big style message");

    NotificationCompat.Builder notificationBuilder =
        new NotificationCompat.Builder(context)
            //.setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle("hallo")
            .setContentText("I am a message")
            .setLargeIcon(BitmapFactory.decodeResource(
                context.getResources(), R.drawable.clock_bg))
            //.setStyle(bigStyle)
            ;

    // Get an instance of the NotificationManager service
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);

    Notification notification =
        new WearableNotifications.Builder(notificationBuilder)
            .setHintHideIcon(true)
            .setMinPriority() // show only on clock
            .build();

    // Build the notification and issues it with notification manager.
    notificationManager.notify(notificationId, notification);
}

何か案が?

これは私の出力です:

時計

4

1 に答える 1

2

正しい方法はWearableExtender、次の短い例で likeを使用することです。

NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender();
Bitmap bg = BitmapFactory.decodeResource(context.getResources(), background);
extender.setBackground(bg);
notificationBuilder.extend(extender);

元の回答 /代替

次のように BigPictureStyle を使用するために必要な解決策を見つけました。

Bitmap background = BitmapFactory.decodeResource(context.getResources(),
                                                 R.drawable.clock_bg);

NotificationCompat.Builder notificationBuilder =
        new NotificationCompat.Builder(context)
                .setContentTitle("hallo")
                .setContentText("I am a message")
                .setLargeIcon(background)
                .setStyle(new NotificationCompat.BigPictureStyle()
                                                .bigPicture(background));
于 2014-03-21T10:23:02.357 に答える