android-通知未显示android api 23及以上版本

android-通知未显示android api 23及以上版本,android,android-notifications,Android,Android Notifications,这是我显示通知的代码,它在Android下面APIlevel23+上工作,但在APIlevel23+上不工作 CharSequence contentText = msg; Intent intent = new Intent(context, MainActivity.class); intent.putExtra("msg",msg); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, Pe

这是我显示通知的代码,它在
Android
下面
API
level23+上工作,但在
API
level23+上不工作

CharSequence contentText = msg;
Intent intent = new Intent(context, MainActivity.class);
intent.putExtra("msg",msg);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

NotificationCompat.Builder b = new NotificationCompat.Builder(context);

b.setAutoCancel(true)
    .setDefaults(Notification.DEFAULT_ALL)
    .setWhen(System.currentTimeMillis())
    .setSmallIcon(getNotificationIcon())
                        .setContentTitle(context.getString(R.string.app_name))
    .setContentText(contentText)
    .setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_SOUND)
    .setContentIntent(contentIntent)
    .setContentInfo("Info");

NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Random rd = new Random();
notificationManager.notify(rd.nextInt(75), b.build());

private int getNotificationIcon() {
    boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
    return useWhiteIcon ? R.drawable.ic_launcher2 : R.mipmap.ic_launcher;
}
我已经为启动器制作了白色图标


这个代码怎么了

请详细解释“it'w not working”是什么意思。@commonware,谢谢回复,这意味着它不显示任何通知。请详细解释“it'w not working”是什么意思。@commonware,谢谢回复,这意味着它不显示任何通知