无法接收要在 Android 自动消息传递应用中显示的通知



我正在尝试创建一个消息传递应用程序来测试Android Auto。但是,我无法让通知显示在 DHU 上。我还用Facebook Messenger进行了测试,它可以工作。

我几乎按照这里的开发指南进行了:https://developer.android.com/training/cars/messaging

只是添加了一些硬编码字符串和图标等进行测试。我已将所需的行添加到清单中。

AndroidManifest.xml:

<application
...
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc"/>
<service
android:name=".MessagingService"
android:exported="true"/>
...
</application>

这是通过按下按钮调用的:

MessagingServiceKt.notify(
getContext(),
new YourAppConversation(
1337,
"Convo title",
new ArrayList<YourAppUser>(Arrays.asList(
new YourAppUser(
1234,
"Test1", 
IconCompat.createWithBitmap(Bitmap.createBitmap(24,24,Bitmap.Config.ALPHA_8))
),
new YourAppUser(
5345,
"Test2",
IconCompat.createWithBitmap(Bitmap.createBitmap(24,24,Bitmap.Config.ALPHA_8)),
)
),
Bitmap.createBitmap(24, 24, Bitmap.Config.ALPHA_8)
)
);

其余代码看起来与示例中几乎相同,但具有对话、用户和消息对象的硬编码数据。

我应该看到DHU单元上弹出的通知,但没有。我也没有收到任何错误,并且所有函数都运行正常。

我刚刚从 Google 支持部门得到了答案,在您的软件包发布并批准用于 Android Auto 之前,您似乎无法让消息传递应用程序在 Android Auto 上运行。

因此,只有从Play商店安装的已批准应用程序才能在Android Auto上运行。

相关内容

最新更新