David Corsalini
David Corsalini

Reputation: 8208

Hangout like list notification on Android Wear

Hangout use a particular Notification that display the list of messages when swiping right on Android Wear. It shows all the messages in a ListView.

Do they use a particular Notification Style (like InboxStyle or BigTextStyle)? Could it be a Wear App? (I don't think so, they are not accessible throght swiping)

Upvotes: 0

Views: 330

Answers (1)

ianhanniballake
ianhanniballake

Reputation: 200020

They are adding Pages to their notification, allowing you to add additional content for Android Wear devices.

Example code from the link:

// Create builder for the main notification
NotificationCompat.Builder notificationBuilder =
    new NotificationCompat.Builder(this)
    .setSmallIcon(R.drawable.new_message)
    .setContentTitle("Page 1")
    .setContentText("Short message")
    .setContentIntent(viewPendingIntent);

// Create a big text style for the second page
BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();
secondPageStyle.setBigContentTitle("Page 2")
           .bigText("A lot of text...");

// Create second page notification
Notification secondPageNotification =
    new NotificationCompat.Builder(this)
    .setStyle(secondPageStyle)
    .build();

// Add second page with wearable extender and extend the main notification
Notification twoPageNotification =
    new WearableExtender()
            .addPage(secondPageNotification)
            .extend(notificationBuilder)
            .build();

// Issue the notification
notificationManager =
    NotificationManagerCompat.from(this);
notificationManager.notify(notificationId, twoPageNotification);

Upvotes: 2

Related Questions