Reputation: 4536
I have Created a project for android wear devices. I need to customize the notification style on the wearable device. Is there any method for that.
My method is
Intent displayIntent = new Intent(getApplicationContext(), CustomNotification.class);
PendingIntent displayPendingIntent = PendingIntent.getActivity(getApplicationContext(),
0, displayIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification =
new NotificationCompat.Builder(context)
.extend(new WearableExtender()
.setDisplayIntent(displayPendingIntent))
.build();
int notificationId = 001;
// Get an instance of the NotificationManager service
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(this);
notificationManager.notify(notificationId , notification);
But i didn't get a notification.
Is there any method to customize with my custom layout design?
and this is the manifest part
<activity android:name="com.client.android.CustomNotification"
android:exported="true"
android:allowEmbedded="true"
android:taskAffinity=""
android:theme="@android:style/Theme.DeviceDefault.Light" />
Upvotes: 2
Views: 3544
Reputation: 10715
Please take a look at the official documentation about creating custom notifications on Android Wear.
You can apply styles to your notificaitons, such as BigPictureStyle
, BigTextStyle
or InboxStyle
.
Here is an example of using BigTextStyle
:
// Specify the 'big view' content to display the long
// event description that may not fit the normal content text.
BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
bigStyle.bigText(eventDescription);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_event)
.setLargeIcon(BitmapFractory.decodeResource(getResources(), R.drawable.notif_background))
.setContentTitle(eventTitle)
.setContentText(eventLocation)
.setContentIntent(viewPendingIntent)
.addAction(R.drawable.ic_map, getString(R.string.map), mapPendingIntent)
.setStyle(bigStyle);
More info:
http://developer.android.com/training/wearables/notifications/creating.html#BigView
You can create a layout in your Activity
and embed it inside your notification:
https://developer.android.com/training/wearables/apps/layouts.html#CustomNotifications
NOTE: Please notice that this approach has some restrictions and will only work for notifications submitted directly from Android Wear device (not from phone).
Please also read the note at the end of that tutorial:
Note: When the notification is peeking on the homescreen, the system displays it with a standard template that it generates from the notification's semantic data. This template works well on all watchfaces. When users swipe the notification up, they'll then see the custom activity for the notification.
Upvotes: 4