【问题标题】:Using the display intent on a page of a wearable notification在可穿戴通知页面上使用显示意图
【发布时间】:2014-11-14 08:04:17
【问题描述】:

我用第二个页面创建了一个可穿戴设备兼容通知,该页面应嵌入自定义活动(在可穿戴设备上)。

以下是可穿戴应用程序清单的相关部分:

<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);

你知道为什么这不能在手机上工作,而是在可穿戴设备本身上工作吗?

【问题讨论】:

    标签: android android-activity android-notifications wear-os


    【解决方案1】:

    您只能通过可穿戴设备本身的嵌入式活动创建和发出自定义通知。

    来自文档:

    您只能在可穿戴设备上创建和发布自定义通知, 并且系统不会将这些通知同步到手持设备。

    Source

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多