我使用第二页创建可穿戴兼容通知,该通知应嵌入自定义活动(在可穿戴设备上)。
以下是可穿戴应用程序中Manifest的相关部分:
<activity android:name=".Test"
android:label="aaa"
android:allowEmbedded="true"
android:taskAffinity=""
android:theme="@android:style/Theme.DeviceDefault.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
这是我手机中的相关安卓代码:
Intent notificationIntent = new Intent();
notificationIntent.setClassName(BuildConfig.APPLICATION_ID, BuildConfig.APPLICATION_ID + ".wear.Main");
PendingIntent notificationPendingIntent = PendingIntent.getActivity(this, 0,
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Bitmap bg = BitmapFactory.decodeResource(getResources(), R.drawable.bg_wearable);
Notification test = new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Title")
.setContentText("Message")
.extend(new NotificationCompat.WearableExtender()
.setBackground(bg)
.addPage(new NotificationCompat.Builder(this)
.setContentTitle("Page 1")
.extend(new NotificationCompat.WearableExtender()
.setDisplayIntent(notificationPendingIntent)
.setCustomSizePreset(NotificationCompat.WearableExtender.SIZE_FULL_SCREEN)
).build()
)
)
.build();
NotificationManagerCompat.from(this).notify(12345, test);
您是否知道为什么这不能在手机上工作,而是在可穿戴设备上工作?
答案 0 :(得分:1)