首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何显示应用程序UI,以接受和拒绝视频呼叫,并防止与其他正在进行的应用程序发生冲突?

如何显示应用程序UI,以接受和拒绝视频呼叫,并防止与其他正在进行的应用程序发生冲突?
EN

Stack Overflow用户
提问于 2017-12-21 09:22:28
回答 2查看 1.1K关注 0票数 3

我在一个android应用程序中工作,其中用户接受或拒绝视频呼叫,这是工作正常。但现在我想防止应用程序与其他人的冲突,如果我们有任何其他呼叫,如什么是应用程序或skype。

然后,我已经阅读了self managed connectionservice并尝试实现它。

Here is complete doc

从活动I首先注册

代码语言:javascript
复制
TelecomManager tm = (TelecomManager) 
        getSystemService(Context.TELECOM_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M)
    {
        PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(
                    new ComponentName(this.getApplicationContext(), MyConService.class),
                    "example");

        PhoneAccount phoneAccount = PhoneAccount.builder(phoneAccountHandle, "example")
                    .setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED).build();
        tm.registerPhoneAccount(phoneAccount);

    }

然后尝试添加新的调用,如下所示:

代码语言:javascript
复制
PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(
                    new ComponentName(this.getApplicationContext(), MyConService.class),
                    "example");
Bundle extras = new Bundle();
Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, "11223344", null);
extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, uri);
tm.addNewIncomingCall(phoneAccountHandle, extras);

应用程序总是在tm.addNewIncomingCall上崩溃,日志如下

代码语言:javascript
复制
/AndroidRuntime: FATAL EXCEPTION: main Process: com.liverep.videochat, PID: 27754
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.liverep.videochat/com.liverep.videochat.VideoChat}: java.lang.SecurityException: This PhoneAccountHandle is not enabled for this user!
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.lang.SecurityException: This PhoneAccountHandle is not enabled for this user!
at android.os.Parcel.readException(Parcel.java:1693)
at android.os.Parcel.readException(Parcel.java:1646)
at com.android.internal.telecom.ITelecomService$Stub$Proxy.addNewIncomingCall(ITelecomService.java:1450)
at android.telecom.TelecomManager.addNewIncomingCall(TelecomManager.java:1225)
at com.liverep.videochat.VideoChat.placeIncomingCall(VideoChat.java:792)
at com.liverep.videochat.VideoChat.call(VideoChat.java:730)
at com.liverep.videochat.VideoChat.registerForPhoneCall(VideoChat.java:716)
at com.liverep.videochat.VideoChat.onCreate(VideoChat.java:133)
at android.app.Activity.performCreate(Activity.java:6942)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988) 
at android.app.ActivityThread.-wrap14(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6682) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) 
EN

回答 2

Stack Overflow用户

发布于 2018-06-18 16:28:31

看起来您在AndroidManifest.xml中没有MANAGE_OWN_CALLS权限

票数 0
EN

Stack Overflow用户

发布于 2019-10-03 22:46:43

正确注册您的PhoneAccount,然后使用addNewIncomingCall()。在我的例子中,它起作用了。

代码语言:javascript
复制
telecomManager.registerPhoneAccount(phoneAccount1);
telecomManager.addNewIncomingCall(myPhoneAccountHandle,bundle);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47916611

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档