Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NotificationCompat v7 and Android O

I am having troubles with NotificationCompat v7 and Android O. Since the implementation of the NotificationCompatV7 only implements the deprecated constructor ( was deprecated in support library 26.0.0-beta1) of the v4 version, I am not able to get Notifications to work.

Solution for NotificationCompat v4 was proposed here: NotificationCompat with API 26

but since there is this issue with the poor implementation of the v7 version (https://issuetracker.google.com/issues/62475846) I am not able to post notifications on Android O

Does anybody have a solution for this or am I missing something here?

like image 653
Mike T Avatar asked Jan 04 '23 19:01

Mike T


1 Answers

NotificationCompat v7 is now deprecated, you should use NotificationCompat v4 (according to the comments on NotificationCompat v7 class ).

/**
 * @deprecated Use the static classes in {@link android.support.v4.app.NotificationCompat}.
 */

Then you can build your notification (Kotlin):

val notificationBuilder = NotificationCompat.Builder(context, "your_notification_channel_name")                     
.setContentTitle("title")
[...]

Note: the latest support version is "com.android.support:appcompat-v7:26.0.0"

like image 165
Marcola Carr Avatar answered Jan 14 '23 13:01

Marcola Carr