Начиная с уведомления оно не попадает в приложение на 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
В Android Automotive Emulator, как запустить приложение на событии Tap об уведомлении? ⇐ Android
Форум для тех, кто программирует под Android
1752081929
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())
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79696015/in-android-automotive-emulator-how-to-launch-the-app-on-tap-event-of-a-notificat[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия