Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何显示应用程序界面以接受和拒绝视频通话,并防止与其他正在运行的应用程序发生冲突?_Android_Android 6.0 Marshmallow_Telecommunication - Fatal编程技术网

Android 如何显示应用程序界面以接受和拒绝视频通话,并防止与其他正在运行的应用程序发生冲突?

Android 如何显示应用程序界面以接受和拒绝视频通话,并防止与其他正在运行的应用程序发生冲突?,android,android-6.0-marshmallow,telecommunication,Android,Android 6.0 Marshmallow,Telecommunication,我在一个android应用程序中工作,用户可以接受或拒绝视频通话,这很好。但现在,我想防止应用程序与其他人冲突,如果我们有任何其他呼叫,如what's app或skype 然后我阅读并尝试实现它 从活动一开始注册 TelecomManager tm = (TelecomManager) getSystemService(Context.TELECOM_SERVICE); if (android.os.Build.VERSION.SDK_INT >= android.os

我在一个android应用程序中工作,用户可以接受或拒绝视频通话,这很好。但现在,我想防止应用程序与其他人冲突,如果我们有任何其他呼叫,如what's app或skype

然后我阅读并尝试实现它

从活动一开始注册

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);

    }
然后尝试通过执行以下操作添加新呼叫:

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(phoneAccountHandle,extras)上崩溃,日志如下

/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) 

看起来您在AndroidManifest.xml中没有权限,请正确注册您的电话帐户,然后使用
addNewIncomingCall()
。就我而言,它起了作用

telecomManager.registerPhoneAccount(phoneAccount1);
telecomManager.addNewIncomingCall(myPhoneAccountHandle,bundle);

嘿,只是个问题;您是否必须使用SIP进行视频通话?不必使用SIP