public static void NotificationPopup(Bitmap bitmap, NotificationManager notificationManager, Context context,String a,String b) {
// R.drawable.qq;
int id = new Random().nextInt(100);
String chanle = "2";
Intent intent = new Intent(context, MainActivity2_Flist.class);
intent.putExtra("id",1);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(
context,
0,
intent,
PendingIntent.FLAG_CANCEL_CURRENT
);
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context, chanle
);
builder.setSmallIcon(R.drawable.wtsxxone);
builder.setDefaults(NotificationCompat.DEFAULT_ALL);
builder.setContentTitle(b);
builder.setContentText(a);
// builder.setStyle(new NotificationCompat.BigTextStyle().bigText("测试"));
// builder.setStyle(new NotificationCompat.BigPictureStyle().bigPicture( BitmapFactory.decodeResource(context.getResources(),R.drawable.bjhhlogin)));
builder.setContentIntent(pendingIntent);
builder.setAutoCancel(true);
builder.setPriority(NotificationCompat.PRIORITY_MAX);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (notificationManager != null && notificationManager.getNotificationChannel(chanle) == null) {
NotificationChannel notificationChannel = new NotificationChannel(
chanle, "1", NotificationManager.IMPORTANCE_HIGH);
notificationChannel.setDescription("123123");
notificationChannel.enableVibration(true);
notificationChannel.enableLights(true);
notificationManager.createNotificationChannel(notificationChannel);
}
}
Notification notification = builder.build();
if (notificationManager != null) {
notificationManager.notify(id, notification);
}
}
效果如下图所示: