Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java android应用程序如何显示像这样的自定义通知?_Java_Android_Kotlin_Notifications - Fatal编程技术网

Java android应用程序如何显示像这样的自定义通知?

Java android应用程序如何显示像这样的自定义通知?,java,android,kotlin,notifications,Java,Android,Kotlin,Notifications,我正在尝试创建一个android应用程序,显示像这样的永久通知 通知如何拥有所有这些UI和图像?以下哪种类型的通知允许此操作: 这回答了你的问题吗? // Get the layouts to use in the custom notification val notificationLayout = RemoteViews(packageName, R.layout.notification_small) val notificationLayoutExpanded = RemoteVie

我正在尝试创建一个android应用程序,显示像这样的永久通知

通知如何拥有所有这些UI和图像?以下哪种类型的通知允许此操作:


这回答了你的问题吗?
// Get the layouts to use in the custom notification
val notificationLayout = RemoteViews(packageName, R.layout.notification_small)
val notificationLayoutExpanded = RemoteViews(packageName, R.layout.notification_large)

// Apply the layouts to the notification
val customNotification = NotificationCompat.Builder(context, CHANNEL_ID)
        .setSmallIcon(R.drawable.notification_icon)
        .setStyle(NotificationCompat.DecoratedCustomViewStyle())
        .setCustomContentView(notificationLayout)
        .setCustomBigContentView(notificationLayoutExpanded)
        .build()