【发布时间】:2014-08-20 18:13:48
【问题描述】:
Android Wear 很可能不支持此功能,但似乎应该有一些解决方法。我想在通知中添加自定义第二页,但我不希望它具有白卡背景。
以下是我创建通知的方式:
Intent secondPageIntent = new Intent(this, SecondPageActivity.class);
PendingIntent secondPagePendingIntent = PendingIntent.getActivity(this, 0, secondPageIntent, 0);
Notification secondPageNotification = new NotificationCompat.Builder(this)
.extend(new NotificationCompat.WearableExtender()
.setDisplayIntent(secondPagePendingIntent)
.setHintShowBackgroundOnly(true)
)
.build();
Intent firstPageIntent = new Intent(this, FirstPageActivity.class);
PendingIntent firstPagePendingIntent = PendingIntent.getActivity(this, 0, firstPageIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.extend(new NotificationCompat.WearableExtender()
.setDisplayIntent(firstPagePendingIntent)
.setBackground(BitmapFactory.decodeResource(getResources(), R.drawable.background))
.addPage(secondPageNotification)
);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.notify(curNotificationId++, builder.build());
我试过了:
- 设置 setHintShowBackgroundOnly 什么都不做
- 在 SecondPageActivity 中,尝试获取 parentActivity 并将其 alpha 设置为 0。不起作用,parentActivity 为 null。
- 调用 setCustomContentHeight(0) 不会移除卡片,它只会变瘦
- 我尝试不使用第二个页面,而是在用户滑动时启动一个活动,但它看起来不太好
我真的不知道接下来要尝试什么。我是一位经验丰富的工程师,但对 Android 还是很陌生。任何想法或建议都会有所帮助。
谢谢!
【问题讨论】:
-
你在下面看到我的回答了吗?如果它对你有用,你能给我任何反馈吗?
标签: android-ui wear-os