I don't get it manages to show the background I did that based on the ElizaChat example but I don't get the background it is always black.
Here is my code:
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);
}
Any Idea?
This is my output:
The right way is to use the WearableExtender
like in this short example:
NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender();
Bitmap bg = BitmapFactory.decodeResource(context.getResources(), background);
extender.setBackground(bg);
notificationBuilder.extend(extender);
Original Answer / alternative
I found a solution I need to use the BigPictureStyle like this:
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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With