【发布时间】:2023-03-20 15:42:01
【问题描述】:
在限制从 android 后台启动活动之后 Q 我正在尝试使用 developer.android 示例代码为我的 VOIP 呼叫构建通知,但它不工作你能帮我解决这个问题吗?
下面的代码是我用来构建时间敏感通知的示例:
Intent fullScreenIntent = new Intent(this, CallActivity.class);
PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(this, 0,
fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("Incoming call")
.setContentText("(919) 555-1234")
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_CALL)
.setFullScreenIntent(fullScreenPendingIntent, true);
Notification incomingCallNotification = notificationBuilder.build();
【问题讨论】:
-
你能帮忙 startForeground(notificationId, notification);我不确定 startForeground 在哪里定义
标签: android android-notifications android-10.0