android 仿微信来电_仿MIUI、微信来电通知无法解决通知折叠到通知列表

求相助,希望有大神帮我解决下,我想做一个类似小米来电的通知功能,我发现小米的来电通知不会自动折叠到通知列表,而我无论如何设置,我的通知都会折叠通知列表里,求助解决方案

如图:来电通知并不会折叠到下拉通知列表

我的通知部分代码:

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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值