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")