java – 如何使用connectionservice实现视频
发布时间:2020-12-15 02:18:52 所属栏目:Java 来源:网络整理
导读:我想通过connectionservice使用系统应用程序实现视频聊天. https://developer.android.com/reference/android/telecom/ConnectionService.html.不幸的是我找不到任何示例或教程如何做到这一点.这就是我所做的: 注册服务: TelecomManager manager = (Teleco
我想通过connectionservice使用系统应用程序实现视频聊天.
https://developer.android.com/reference/android/telecom/ConnectionService.html.不幸的是我找不到任何示例或教程如何做到这一点.这就是我所做的:
注册服务: TelecomManager manager = (TelecomManager) getSystemService(TELECOM_SERVICE); PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(new ComponentName(getBaseContext().getPackageName(),PhoneConnectionService.class.getName()),"myConnectionServiceId"); PhoneAccount.Builder builder = PhoneAccount.builder(phoneAccountHandle,Localization.localize(R.string.IDS_APP_NAME_SHORT)); builder.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER | PhoneAccount.CAPABILITY_CONNECTION_MANAGER| PhoneAccount.CAPABILITY_VIDEO_CALLING ); PhoneAccount phoneAccount = builder.build(); manager.registerPhoneAccount(phoneAccount); 拨打电话: TelecomManager manager = (TelecomManager) context.getSystemService(TELECOM_SERVICE); PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(new ComponentName(context.getPackageName(),"estosConnectionServiceId"); Bundle test = new Bundle(); test.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE,phoneAccountHandle); test.putInt(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE,VideoProfile.STATE_BIDIRECTIONAL); test.putParcelable(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS,extras); manager.placeCall(Uri.parse("tel:" + number),test); 我的ConnectionService被调用了 @Override public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount,ConnectionRequest request) { Connection conn = new MyAndroidCallConnection(); conn.setAddress(request.getAddress(),PRESENTATION_ALLOWED); conn.setInitializing(); conn.setVideoProvider(new MyVideoProvider()); conn.setActive(); return conn; } 我将我的视频录像机放入系统要求的连接中. 解决方法
我只是忘了添加conn.setVideoState(VideoProfile.STATE_BIDIRECTIONAL);我的连接不仅仅是在placeCall上.现在按预期访问VideoProvider
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |