Java – how to implement video using connectionservice
I want to use the system application to realize video chat through connection service https://developer.android.com/reference/android/telecom/ConnectionService.html. Unfortunately, I can't find any examples or tutorials on how to do this That's what I did:
Registration service:
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);
Call:
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);
My connectionservice was called
@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; }
I put my video recorder into the connection required by the system The phone activity appears and shows me the call through the small camera sign, so the system knows what I want to do I now expect to call the videoprovider method from the system in some way to give me the surface of the video, etc., but no method is called Someone knows what I did wrong or where to find a good example of this topic
Solution
I just forgot to add conn.setvideostate (videoprofile. State_bidirectional); My connection is not just on placecall Now access the videoprovider as expected