首页 > 解决方案 > 不带抬头视图的通知

问题描述

这可能与这个问题重复, 但仍然无法在没有抬头视图的情况下实施通知。

问题陈述:想在播放歌曲时显示通知。将一个通知与浮动在窗口顶部的音乐服务绑定(显示平视视图),这非常烦人。

有什么方法可以禁用该抬头视图,只想在状态栏中显示一个小图标。

       mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL)
                .setContentTitle("titile")
                .setContentText("desc")
                .setSmallIcon(R.drawable.logo)
                .setColor(getResources().getColor(R.color.colorPrimary))
                .setPriority(NotificationCompat.PRIORITY_LOW)
                .setAutoCancel(true);
        Notification notification = notificationBuilder.build();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel notificationChannel = new NotificationChannel(
                    CHANNEL, "Halt", NotificationManager.IMPORTANCE_NONE
            );
            mNotificationManager.createNotificationChannel(notificationChannel);
        }
        mNotificationManager.notify(NOTIFICATION_ID, notification);

标签: androidandroid-notifications

解决方案


花了一些时间后,我只是卸载并重新安装应用程序并开始工作。

越野车岩石


推荐阅读