Notification working as expected in all Android versions but not in latest Android O.
I figured out the issue will be because they have introduces ChannelIds and that are mandatory to use in Android O.
Currently insted of Notification iam getting following Toast message in Android O device.

I have resolved this issue with following code changes :
Append NotificationChannel to the NotificationManager :
mNotificationManager = (android.app.NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel chan1 = new NotificationChannel(PRIMARY_CHANNEL, mContext.getString(R.string.app_name), android.app.NotificationManager.IMPORTANCE_DEFAULT); mNotificationManager.createNotificationChannel(chan1);
Add above channel to Notification Builder:
NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext , PRIMARY_CHANNEL);
Channel value is :
public static final String PRIMARY_CHANNEL = "default";
Thats it everything is woking after this change.
For more info please refer following links:
https://stackoverflow.com/questions/44489657/android-o-reporting-notification-not-posted-to-channel-but-it-is
https://stackoverflow.com/questions/45668079/notificationchannel-issue-in-android-o
No comments:
Post a Comment