按月网站建设,wordpress关闭主题,温州市网站建设公司,咸阳做网站Android studio 使用 targetSdkVersion 28 在Android系统大于等于8.0的时候#xff0c;通知不显示bug解决方法#xff1a; 1、修改appcompat版本#xff0c;如果是小于v27
改为
implementation com.android.support:appcompat-v7:27.1.1
2、添加依赖
compile com.git…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) import static me.nereo.multi_image_selector.MultiImageSelectorFragment.TAG;
附
NotificationCompat.Builder mBuilder new NotificationCompat.Builder(APPlocation.getTotalContext());
NotificationManager mNotificationManager (NotificationManager) APPlocation.getTotalContext().getSystemService(Context.NOTIFICATION_SERVICE);if (Build.VERSION.SDK_INT Build.VERSION_CODES.O) {NotificationChannel channel new NotificationChannel(com.tianxin.service2thread,TAG,NotificationManager.IMPORTANCE_DEFAULT);mNotificationManager.createNotificationChannel(channel);}mBuilder.setChannelId(com.tianxin.service2thread);
mBuilder.setContentText(内容);
Intent notificationIntent new Intent(this, TwoActivity.class);
PendingIntent pendingIntent PendingIntent.getActivity(this, 0,notificationIntent, 0);
mBuilder.setContentIntent(pendingIntent);
mBuilder.setSmallIcon(R.mipmap.ic_launcher);
mNotificationManager.notify(1, mBuilder.build());