仿照小米、微信来电通知

*若价格不公道,可以让提问者在平台追加赏金哦,平台是您利益的保证

待解决
仿照小米、微信来电通知-﹏﹖7”
﹏﹖7” 1年前发布
悬赏:10.0 元

问题详情:分类: Android

求相助,希望有大神帮我解决下,我想做一个类似小米来电的通知功能,我发现小米的来电通知不会自动折叠到通知列表,而我无论如何设置,我的通知都会折叠通知列表里,求助解决方案
@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.setLightColor(Color.GREEN);
//@see https://blog.csdn.net/mingtiannihao0522/article/details/83584038
//@see https://www.jianshu.com/p/99bc32cd8ad6
notificationChannel.setSound(null, null);

// // 需要设置震动,但时长为0
// // NotificationChannel在创建时就确定了震动和声音属性,后续再创建时不会覆盖这部分属性
// // 现改为开启震动,但震动时长0,达到不震动的目的,单只设置enableVibration是没有用的
// notificationChannel.enableVibration(true);
// notificationChannel.setVibrationPattern(new long[]{0});
notificationChannel.setImportance(NotificationManager.IMPORTANCE_HIGH);
return notificationChannel;
}

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);
}


*若价格不公道,可以让提问者在平台追加赏金哦,平台是您利益的保证。你觉得当前的价格如何呢,奉上您珍贵的一票吧

虚高0人次 适中0人次 偏低0人次

分享海报会更快解决你的问题哦!分享海报

此处可发布评论

评论(0

暂无评论,快来写一下吧
客服QQ 1913284695