美文网首页
android Notification 弹出横幅

android Notification 弹出横幅

作者: lesliefang | 来源:发表于2020-05-19 18:53 被阅读0次
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationCompat.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    NotificationChannel notificationChannel = new NotificationChannel("braun", "braun", NotificationManager.IMPORTANCE_DEFAULT);
    manager.createNotificationChannel(notificationChannel);
    builder = new NotificationCompat.Builder(this, "braun");
} else {
    builder = new NotificationCompat.Builder(this);
}

Intent intent = new Intent(this, DownloadActivity.class);
intent.putExtra("drugList", drugList);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 100, intent, PendingIntent.FLAG_UPDATE_CURRENT);

builder.setContentTitle(bedIndex + " " + patientName + " 有新的医嘱可下发")
        .setContentText(content)
        .setSmallIcon(R.drawable.nurse_head)
        .setDefaults(NotificationCompat.DEFAULT_VIBRATE | NotificationCompat.DEFAULT_LIGHTS)
        .setContentIntent(pendingIntent)
        .setFullScreenIntent(pendingIntent, true)
        .setAutoCancel(true)
        .build();
manager.notify(1, builder.build());

setFullScreenIntent(pendingIntent, true) 会在顶部弹出一个横幅

相关文章

网友评论

      本文标题:android Notification 弹出横幅

      本文链接:https://www.haomeiwen.com/subject/opciohtx.html