【发布时间】:2019-01-23 02:40:15
【问题描述】:
我正在开发一个自定义呼叫应用程序,当用户在来电期间将应用程序置于后台时,我必须在其中放置一个 UI。我正在显示通知,但我的 IncomingCallActivity 没有恢复。 是否可以在来电期间在所有应用程序上放置 UI“返回通话”?
通知代码如下:
private void createNotification() {
// Create an explicit intent for an Activity in your app
Intent intent = new Intent(this, IncomingCallActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.pref_noti_icon)
.setContentTitle(this.getResources().getString(R.string.app_name))
.setContentText(this.getResources().getString(R.string.notification_return_to_call))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
// Set the intent that will fire when the user taps the notification
.setContentIntent(pendingIntent)
.setAutoCancel(true);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}
【问题讨论】:
-
亲爱的@ADM 我已经编辑了我的问题,现在看来它指向了我真正的问题。请考虑撤回反对票。谢谢你
-
您不需要将
"return to call放在 Window 上。只需为 Activity 提供PendingIntent,它将打开相同的 InCallActivity onClick 通知。确保您为 InCallActivity 使用正确的启动模式。此外,您应该使用带有通知的操作来挂断电话。只需从任何 System Phone APP 中获取参考即可。
标签: android android-intent notifications call