匿名通知将折叠到通知列表中

时间:2020-06-02 12:28:20

标签: android android-notifications

请帮助我。我希望一个很棒的SomeBody可以帮助我解决这个问题。 我想使通知功能类似于MiUi的来电。我发现小米的电话通知不会自动折叠到通知列表中。 但是,设置完成后,我的通知将被折叠到通知列表中以寻求解决方案

enter image description here

通知:

    public static void buildCallNotification(Service service, final PendingIntent resultPendingIntent) {
        Log.d(TAG,"buildCallNotification");
        NotificationCompat.Builder builder;
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            builder = new NotificationCompat.Builder(service, NotificationChannelsUtils.CALL_CHANNEL);
        } else {
            builder = new NotificationCompat.Builder(service);
        }
        builder.setSmallIcon(getSmallIconResId())
                .setContentTitle(service.getResources().getText(R.string.channel_call))
                .setCategory(NotificationCompat.CATEGORY_CALL)
                .setContentIntent(resultPendingIntent)
                .setTicker(service.getResources().getText(R.string.channel_call))
                .setFullScreenIntent(resultPendingIntent,true)
                .setPriority(NotificationCompat.PRIORITY_MAX)
                .setOngoing(true);

        Notification notification = builder.build();
        service.startForeground(NOTIFICATION_ID_INCOMINGCALL, notification);
    }

频道:

    @RequiresApi(api = Build.VERSION_CODES.O)
    private static NotificationChannel getCallChannel(Context context){
        NotificationChannel notificationChannel = new NotificationChannel(CALL_CHANNEL, context.getString(R.string.channel_call), NotificationManager.IMPORTANCE_HIGH);
        notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
        notificationChannel.setSound(null, null);
        notificationChannel.setImportance(NotificationManager.IMPORTANCE_HIGH);
        return notificationChannel;
    }

0 个答案:

没有答案