我已经为android穿戴设备创建了一个项目。我需要定制可穿戴设备上的通知样式。有什么方法吗。
我的方法是
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);但我没收到通知。
是否有任何方法可自定义我的自定义布局设计?
这是最明显的部分
<activity android:name="com.client.android.CustomNotification"
android:exported="true"
android:allowEmbedded="true"
android:taskAffinity=""
android:theme="@android:style/Theme.DeviceDefault.Light" />发布于 2014-07-24 11:39:51
请查看有关在Android磨损上创建自定义通知的官方文档。
使用大视图:
可以将样式应用于通知程序,如BigPictureStyle、BigTextStyle或InboxStyle。
下面是一个使用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);更多信息:
http://developer.android.com/training/wearables/notifications/creating.html#BigView
使用自定义通知布局:
您可以在Activity中创建布局,并将其嵌入通知:https://developer.android.com/training/wearables/apps/layouts.html#CustomNotifications中。
注意:请注意,这种方法有一些限制,只适用于直接从安卓穿戴设备(而不是从电话)提交的通知。
请阅读本教程末尾的说明:
Note:当通知在主屏幕上查看时,系统会用它从通知的语义数据生成的标准模板显示它。这个模板在所有的观察面上都能很好地工作。当用户滑动通知时,他们将看到通知的自定义活动。
https://stackoverflow.com/questions/24932243
复制相似问题