在我的应用程序中,我编写了一个简单的通知函数,该方法仅在状态栏上显示图标,我希望还能够显示通知布局,但它不会自动显示,我需要拉下Android状态栏才能看到。
public static void createNotification(Context context, Class activity, String title, String subject, int count_unread_message) {
Intent intent = new Intent(context, activity);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
Notification notify = new NotificationCompat.Builder(context)
.setAutoCancel(true)
.setContentTitle(title)
.setContentText(subject)
.setSmallIcon(R.mipmap.ic_launcher)
.setNumber(count_unread_message)
.setPriority(0)
.setLights(Color.BLUE, 500, 500)
.setContentIntent(pendingIntent)
.build();
notify.flags |= Notification.FLAG_AUTO_CANCEL;
NOTIFICATIONMANAGER = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
NOTIFICATIONMANAGER.notify(159753456, notify);
}
看起来这个问题是针对 Android 6 及以上版本的。