В Android Automotive Emulator, как запустить приложение на событии Tap об уведомлении?Android

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Anonymous
 В Android Automotive Emulator, как запустить приложение на событии Tap об уведомлении?

Сообщение Anonymous »

Начиная с уведомления оно не попадает в приложение на Android Automotive Emulator. Но то же самое работает на автомобильном устройстве Android. Есть ли способ сделать эту работу на эмулятор? getPendingIntent ()) < /p>
private fun showNotification(title: String, messageBody: String, pendingIntent: PendingIntent)
{
Log.i(TAG, "showNotification: ")
val defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
val notificationBuilder = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {

NotificationCompat.Builder(fbCarContext, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(title).setContentText(messageBody).setAutoCancel(true)
.setContentText(messageBody)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
.setPriority(NotificationManager.IMPORTANCE_HIGH)
.setDefaults(Notification.DEFAULT_SOUND.or(Notification.DEFAULT_VIBRATE))
.setCategory(Notification.CATEGORY_MESSAGE)

}
else {
NotificationCompat.Builder(fbCarContext, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(title).setContentText(messageBody).setAutoCancel(true)
.setContentText(messageBody)
.setSound(defaultSoundUri).setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setDefaults(Notification.DEFAULT_SOUND.or(Notification.DEFAULT_VIBRATE))
.setCategory(Notification.CATEGORY_MESSAGE)
}
val notificationManager = fbCarContext.getSystemService(CarContext.NOTIFICATION_SERVICE) as NotificationManager

// Since android Oreo notification channel is needed.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(CHANNEL_ID, fbCarContext.getString(R.string.channelhrt), NotificationManager.IMPORTANCE_HIGH)
notificationManager.createNotificationChannel(channel) }
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build())
}


Подробнее здесь: https://stackoverflow.com/questions/796 ... -notificat
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Android»