1

In handheld devices, custom notifications can be displayed using RemoteViews. RemoteViews allows the developer to fully customise the notification.

What is the way to do the same for Android Wear? Which class should be used to override the default notification UI with my own customised one?

Swayam
  • 16,294
  • 14
  • 64
  • 102
  • I have updated my answer as it is possible, take a look here: http://stackoverflow.com/questions/28603086/custom-ui-for-android-wear-notifications/ – Michał Tajchert Apr 18 '15 at 16:50

3 Answers3

4
  1. if you want to customize text only, you can use SpannableString. It allows you to change color, background, align of your title/content text.

  2. if you want to create totally different notification you have to implement smth similar in your wear project

    Intent notificationIntent = new Intent(context, WearNotificationActivity.class);
    PendingIntent pendingNotificationIntent =
            PendingIntent.getActivity(context, 0, notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
    
        Notification notification =
                new Notification.Builder(context)
                        .setSmallIcon(R.drawable.ic_launcher)
    
                       // .setContentTitle("CustomNotification")
                        .extend(new Notification.WearableExtender()
                                .setDisplayIntent(pendingNotificationIntent)
                                .setCustomSizePreset(Notification.WearableExtender.SIZE_LARGE)
                                .setStartScrollBottom(false)
                                .setHintHideIcon(true))
    
                        .build();
    
        NotificationManager notificationManager =
                (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
    
        notificationManager.notify(0, notification);
    

where WearNotificationActivity - activity container of you custom view.

NOTE: you HAVE TO use .setSmallIcon(..) even if you don't need it. Seems like a google bug, but without this line notification won't be shown.

and set

 android:allowEmbedded="true"
 android:taskAffinity=""

for your activity container

Vika L.
  • 265
  • 1
  • 11
1

To create a rich Notification for Android Wear, you have to use NotificationCompat.Builder from support-v4.

This version gives you a better control of the notification layout on Wear with methods such as .setActionButton() or .setStyle().

You can even more customize your notification with a NotificationCompat.WearableExtender.

Learn more at Creating a Notification

pdegand59
  • 12,776
  • 8
  • 51
  • 58
  • Thank you for the answer, but I am already finished with this part. NotificationCompat and WearableExtender only allow us to define actions and set the action icons. What I am looking to do is create a totally customised notification. – Swayam Nov 19 '14 at 11:20
0

Currently there is no way to do that. EDIT: it is possible: Custom UI for Android Wear Notifications

Best option out there are:

  • Create Notification on phone and use NotificationCompat.WearableExtendernotification for both phone and Wear.
  • Create Notification with setLocalOnly() so notification will be limited to phone, and on Wear create separate one - with other look, actions etc.
  • Do as above but instead of notification on Wear create own app with CardFrames (that allows you to have "notification style" and custom layout at same time, and when receiving signal from phone run your app instead of notification.

So only last option allows you to have custom layout but there are many drawback (as it is own app) - for example it is separate from notification list.

Hope that might change in the future.

Community
  • 1
  • 1
Michał Tajchert
  • 10,333
  • 4
  • 30
  • 47