- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用桌面主机,我有以下代码将对话推送到该单元,请记住,我在未决 Intent 上设置了 null,因为我不需要任何 Hook /回调。我只想在 android auto 处于 Activity 状态时发送通知。这是不起作用的代码:
private void pushAndroidAutoUnreadConversation(String msg) {
// Build a RemoteInput for receiving voice input in a Car Notification
RemoteInput remoteInput = new RemoteInput.Builder(MY_VOICE_REPLY_KEY)
.setLabel(msg)
.build();
// Create an unread conversation object to organize a group of messages
// from a particular sender.
UnreadConversation.Builder unreadConvBuilder =
new UnreadConversation.Builder("my apps conversation")
.setReadPendingIntent(null)
.setReplyAction(null, remoteInput);
unreadConvBuilder.addMessage(msg)
.setLatestTimestamp(System.currentTimeMillis());
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(),
R.drawable.icon);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.icon)
.setLargeIcon(largeIcon).setContentTitle(msg);
notificationBuilder.extend(new NotificationCompat.CarExtender()
.setUnreadConversation(unreadConvBuilder.build()));
NotificationManagerCompat msgNotificationManager =
NotificationManagerCompat.from(this);
msgNotificationManager.notify("my_apps_tag",
Integer.parseInt(MY_VOICE_REPLY_KEY), notificationBuilder.build());
}
MY_VOICE_REPLY_KEY 只是一个数字,它是 9675
这是我的 build.gradle 文件:
应用插件:'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "org.myapp.easy"
minSdkVersion 9
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('old_proguard-android.txt')
}
}
}
dependencies {
compile files('libs/GoogleAdMobAdsSdk-4.1.1.jar')
compile 'com.android.support:support-v4:21.0.2'
}
这是 list 的一部分:
<application
android:allowBackup="false"
android:icon="@drawable/icon"
android:label="@string/app_name" >
<meta-data android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
这是我放在 xml 文件夹中的 automotive_app_desc.xml:
<automotiveApp>
<uses name="notification"/>
</automotiveApp>
我在看官方教程here
我假设当我创建通知时,物理通知应该出现在 android 自动仪表板中,但我什么也没看到。但是在移动设备上我看到了我的通知。让我解释一下发生了什么。在插入汽车之前,我正在创建一条消息方式。因此,当用户与汽车断开连接时,此方法就会运行。当用户连接到 android auto 时,我希望这个通知应该显示在仪表板上,但它没有,但我在移动设备通知托盘上看到它。
最佳答案
终于找到问题了。我正在为未决 Intent 传递 null。它不想那样。我必须为听到的消息和回复的消息制定未决 Intent ,并将它们实际设置在 UnreadConversation.Builder 中,如下所示:
UnreadConversation.Builder unreadConvBuilder =
new UnreadConversation.Builder("reminder note")
.setReadPendingIntent(msgHeardPendingIntent)
.setReplyAction(msgHeardPendingIntent, remoteInput);
所以它似乎不喜欢 setReadPendingIntent 和 setReplyAction 为 null。
关于Android auto - 推送未读对话的代码不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33534715/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!