在显示前台通知时触发广播接收器时打开应用程序

问题描述

我正在使用PJSIP开发一个Android VoIP应用程序。打开应用程序后,通话接收和发送就不会发生任何故障。但是,由于我希望我的应用在关闭时能够监听来电,因此我实现了前台通知。 在服务类的“ onStartCommand()”方法中,添加了以下代码以启动前台通知

Intent incomingIntent = new Intent(getApplicationContext(),IncomingCallActivity.class);
PendingIntent receiveCallPendingIntent = PendingIntent.getbroadcast(
                getApplicationContext(),1200,incomingIntent,PendingIntent.FLAG_UPDATE_CURRENT
        );

createChannel();
NotificationCompat.Builder notificationBuilder = new            NotificationCompat.Builder(this,CHANNEL_ID)
                .setContentText(intent.getStringExtra(ParaM_disPLAY_NAME))
                .setContentTitle("Incoming Call")
                .setSmallIcon(R.mipmap.ic_launcher_1)
                .setPriority(NotificationCompat.PRIORITY_HIGH)
                .setCategory(NotificationCompat.CATEGORY_CALL)
                .addAction(R.drawable.ic_add_black_24dp,"Answer",receiveCallPendingIntent)
                .setAutoCancel(true)
                .setFullScreenIntent(receiveCallPendingIntent,true);
Notification incomingCallNotification = notificationBuilder.build(); 
startForeground(120,incomingCallNotification);

我还在Manifest.xml文件中包含了我的Service类和broadcastReceiver。另外,我已经在应用程序上下文中注册了我的接收器。

问题是,即使我看到该应用程序正在接收广播意图,当该应用程序关闭时(前景通知仍然存在),它也不会打开我的应用程序。基本上,我希望我的应用程序在有人呼叫时启动活动,以便用户可以看到有人在呼叫。任何帮助将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)