视频直播源码,SystemUI 悬浮通知

发布时间 2023-09-15 14:13:49作者: 云豹科技-苏凌霄

视频直播源码,SystemUI 悬浮通知

简单通知创建代码

 


    public void showAlarmNotification() {
        //IMPORTANCE_HIGH 重要通知,弹出悬浮通知
        NotificationChannel channel = new NotificationChannel("123", "测试 channel_name", NotificationManager.IMPORTANCE_HIGH);
        //led灯
        channel.enableLights(true);
        //锁屏显示通知
        channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
        //led灯颜色
        channel.setLightColor(Color.BLUE);
 
        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        notificationManager.createNotificationChannel(channel);
 
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.baidu.com"));
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
 
        // Get the layouts to use in the custom notification
        RemoteViews notificationLayout = new RemoteViews(getPackageName(), R.layout.notification_layout);
        notificationLayout.setTextViewText(R.id.text, "contentView");
 
        RemoteViews notificationLayoutExpanded = new RemoteViews(getPackageName(), R.layout.notification_layout_big);
        notificationLayoutExpanded.setTextViewText(R.id.text, "bigContentView");
 
        // Apply the layouts to the notification
        Notification customNotification = new NotificationCompat.Builder(this, "123")
                .setSmallIcon(R.mipmap.ic_launcher_round)
                .setContentTitle("imageTitle")
                .setContentText("imageDescription")
                .setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.ic_android_black_24dp))
                .setStyle(new NotificationCompat.BigPictureStyle()
                        .bigPicture(BitmapFactory.decodeResource(getResources(),R.drawable.ic_android_black_24dp))
                        .bigLargeIcon(null))
                .setFullScreenIntent(pendingIntent, false)
                .build();
 
        notificationManager.notify(0, customNotification);
    }

 以上就是 视频直播源码,SystemUI 悬浮通知,更多内容欢迎关注之后的文章