如何解决我们遇到了在 Redmi note 6 pro 和 Redmi note 8 pro 设备中未显示呼叫通知弹出的问题
我们已经在 pcloudy 中检查了印度 Redmi note 6 Pro 设备和 Redmi note 8 pro 设备。通知弹出显示,但在以色列国家相同的设备它不工作。
请检查我的代码,如果有任何解决方案,请在此处发表评论。 android 10 和 11 中的呼叫通知不显示。
java`
public void showNotificationForIncomingCall(SipCallSession callInfo) {
@SuppressWarnings("deprecation")
int icon = android.R.drawable.stat_sys_phone_call;
CharSequence tickerText = context.getText(R.string.ongoing_call);
long when = System.currentTimeMillis();
Intent callNotifIntent;
tickerText = context.getText(R.string.incoming_call);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (inComingCallNotification == null) {
inComingCallNotification = new Builder(context);
inComingCallNotification.setSmallIcon(icon);
inComingCallNotification.setTicker(tickerText);
inComingCallNotification.setPriority(NotificationCompat.PRIORITY_HIGH);
inComingCallNotification.setCategory(NotificationCompat.CATEGORY_CALL);
inComingCallNotification.setWhen(when);
inComingCallNotification.setChannelId(IN_CHANNEL_ID);
inComingCallNotification.setongoing(true);
}
} else {
if (inComingCallNotification == null) {
inComingCallNotification = new Builder(context);
inComingCallNotification.setSmallIcon(icon);
inComingCallNotification.setTicker(tickerText);
inComingCallNotification.setDefaults(Notification.DEFAULT_ALL);
inComingCallNotification.setWhen(when);
inComingCallNotification.setongoing(true);
}
}
RemoteViews notificationLayoutHeadsUp =
new RemoteViews(
context.getPackageName(),R.layout.incoming_call_notification_heads_up);
`notificationLayoutHeadsUp.setTextViewText(R.id.sip_uri,` formatRemoteContactString(callInfo.getRemoteContact(),callInfo));
// notificationLayoutHeadsUp.setTextViewText(R.id.incoming_call_info,"Start Forwarding");
/*if (contactIcon != null) {
notificationLayoutHeadsUp.setimageViewBitmap(R.id.caller_picture,contactIcon);
}*/
Log.d("Notification: ","showNotification: called: ");
Intent hangupIntent = new Intent(context,NotificationbroadcastReceiver.class);
String INTENT_CANCEL_CALL_FORWARDING_ACTION = "com.android.cancel_call";
hangupIntent.setAction(INTENT_CANCEL_CALL_FORWARDING_ACTION);
Intent startIntent = new Intent(context,NotificationbroadcastReceiver.class);
String INTENT_START_CALL_FORWARDING_ACTION = "com.android.start_call";
startIntent.setAction(INTENT_START_CALL_FORWARDING_ACTION);
PendingIntent hangupPendingIntent =
PendingIntent.getbroadcast(context,131,hangupIntent,PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent startPendingIntent =
PendingIntent.getbroadcast(
context,startIntent,PendingIntent.FLAG_UPDATE_CURRENT);
notificationLayoutHeadsUp.setonClickPendingIntent(R.id.accept_btn,startPendingIntent);
notificationLayoutHeadsUp.setonClickPendingIntent(R.id.reject_btn,hangupPendingIntent);
prefManager.setBackgroundCall(true);
Intent notificationIntent = SipServiceNew.buildCallUiIntent(context,callInfo);
PendingIntent contentIntent = PendingIntent.getActivity(context,notificationIntent,0);
enter code here
inComingCallNotification.setContentText(formatRemoteContactString(callInfo.getRemoteContact(),callInfo));
inComingCallNotification.setContentIntent(contentIntent);
inComingCallNotification.setongoing(true)
// .setFullScreenIntent(contentIntent,true)
// .setCustomHeadsUpContentView(notificationLayoutHeadsUp)
.addAction(R.drawable.cancel_forwarding_bg,"Decline",hangupPendingIntent)
.addAction(R.drawable.start_forwarding_bg,"Accept",startPendingIntent)
.setVisibility(Notification.VISIBILITY_PUBLIC);
Notification notification = inComingCallNotification.build();
notification.flags |= Notienter code herefication.FLAG_NO_CLEAR;
notificationmanager.notify(131,notification);
}
}
}
`
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。