在特定设备的通话过程中没有显示抬头通知

问题描述 投票:0回答:1

我正在开发一个应用程序,该应用程序在打入或打出电话时会显示抬头通知(在未通话时进行测试并可以正常工作)。该功能可以在许多设备(小米,华为,Oppo设备)上完美运行。但是在最新的三星设备中,不会显示抬头通知。相反,通知保留在通知中心,用户必须向下滑动才能看到通知。还有其他人遇到类似的问题并有解决方案吗?

代码段:

private var manager: NotificationManager? = null

 val manger: NotificationManager
    get() {
        if(manager==null) {
            manager = if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                applicationContext.getSystemService(NotificationManager::class.java)
            } else {
                applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
            }
        }
        return manager!!
    }

private fun createNotificationChannel() {
      if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        val mChannel = NotificationChannel(ID,NAME,NotificationManager.IMPORTANCE_HIGH)
    mChannel.setShowBadge(true)
    mChannel.enableVibration(true)
    mChannel.lockscreenVisibility=Notification.VISIBILITY_PUBLIC

    manger.createNotificationChannel(mChannel)

      }
  }

public static NotificationCompat.Builder showNotification(Context context, String notificationChannel, String Message, String title) {
        Bitmap picture = Utils.decodeResource(context.getResources(), R.drawable.notifi, 64, 64);
        return new NotificationCompat.Builder(context, notificationChannel)
                .setLargeIcon(picture)
                .setSmallIcon(R.drawable.splash_logo)
                .setColor(context.getResources().getColor(R.color.colorPrimaryDark))
                .setContentTitle(title)
                .setContentText(Message)
                .setAutoCancel(true)
                .setOngoing(true)
                .setDefaults(DEFAULT_SOUND | DEFAULT_VIBRATE)
                .setPriority(NotificationCompat.PRIORITY_MAX)
                .setCategory(Notification.CATEGORY_CALL)
                .setVibrate(new long[0])
                .setTimeoutAfter(10000);
    }
android android-notifications samsung-mobile heads-up-notifications
1个回答
1
投票

在android中-抬头通知具有内置的速率限制。

[如果用户向上滑动抬头通知(将其放回通知托盘中)或向侧面滑动(将其消散),则这会向系统发出信号,以防止在一段时间(一分钟内再发送一次抬头通知)默认)。

© www.soinside.com 2019 - 2024. All rights reserved.