NotificationManager: notifyAsUser: tag=null, id=6, user=UserHandle{0}

Android studio 使用   targetSdkVersion 28  在Android系统大于等于8.0的时候,通知不显示bug解决方法:

 

1、修改appcompat版本,如果是小于v27

改为

implementation 'com.android.support:appcompat-v7:27.1.1'

2、添加依赖

compile 'com.github.lovetuzitong:MultiImageSelector:1.2'

3、添加如果系统版本大于等于 8.0 设置NotificationChannel代码

NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    NotificationChannel channel = new NotificationChannel(
            "com.tianxinyw.mapclient.liteapp",
            TAG,
            NotificationManager.IMPORTANCE_DEFAULT

    );

    mNotificationManager.createNotificationChannel(channel);

}

4、builder添加通道setChannelId

Notification.Builder builder = new Notification.Builder(this);

 

builder.setChannelId("com.tianxinyw.mapclient.liteapp")
    原文作者:meixi_android&java
    原文地址: https://blog.csdn.net/meixi_android/article/details/83379335
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞