Хорошо, ребята, idk, почему, но уведомления не отображаются, на телефоне с API 29. На Api 21, например, все в порядке. Да, я пытался читать другие сообщения на SO и не нашел там ничего полезного, попробовал все советы из этих сообщений тоже.
Мин. SDK 24, Макс. SDK - 29 в Gradle
Получатель в манифесте:
<receiver android:name=".ui.more_content.receivers.RemindersReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
Класс получателя:
class RemindersReceiver: BroadcastReceiver() {
override fun onReceive(p0: Context?, p1: Intent?) {
// Идентификатор уведомления
if(p1?.action.equals("android.intent.action.PACKAGE_ADDED")||p1?.action.equals("android.intent.action.PACKAGE_REMOVED")
||p1?.action.equals("android.intent.action.PACKAGE_UPDATED")) {
showNotificationWith("qwqwdqwqs", p0)
}
}
private fun showNotificationWith(message: String, context: Context?) {
val channelId = "com.example.notif.channelId"
val channelName = "App status"
val contentTitle = "Title"
val notificationManager =
context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val activityIntent = Intent()
val contentIntent: PendingIntent = PendingIntent.getActivity(
context,
0, activityIntent, PendingIntent.FLAG_CANCEL_CURRENT
)
val largeIcon: Bitmap = BitmapFactory.decodeResource(context.resources, R.drawable.info)
val notificationBuilder = NotificationCompat.Builder(context, channelId)
.setSmallIcon(R.drawable.info)
.setContentTitle(contentTitle)
.setContentText("asdasdasdasdas")
.setStyle(
NotificationCompat.BigTextStyle()
.bigText(context.getString(R.string.long_dummy_text))
.setBigContentTitle("Big content title")
.setSummaryText("Summary is this Text")
)
.setLargeIcon(largeIcon)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setColor(Color.RED)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
val importance = NotificationManager.IMPORTANCE_HIGH
val notificationChannel = NotificationChannel(channelId, channelName, importance)
notificationBuilder.setChannelId(channelName)
notificationManager.createNotificationChannel(notificationChannel)
notificationManager.notify(
message.hashCode(), notificationBuilder
.setContentIntent(contentIntent).setAutoCancel(true).build()
)
} else {
notificationManager
.notify(
message.hashCode(), notificationBuilder
.setContentIntent(contentIntent).setAutoCancel(true).build()
)
}
}
}
Ценю любую помощь , thx в форварде