``
I am trying to implement Android custom dialer. Able to make calls and receive incoming call using intents. But we need out own ConnectionService implementation for basic call. If basic calls works then we need to implement conference and transfer also.
*
Issue is call not reaching to destination phone. just initiating call
where I did mistake, please help me what to do?`
Need ConnectionService implementation for basic call.
RequiresApi(api = Build.VERSION_CODES.M) public class TekVConnectionService extends ConnectionService { private final List<TekVConnection> mCalls = new ArrayList<>(); private MediaPlayer mMediaPlayer; @Override public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) { TekVConnection connection = new TekVConnection(true, request,this); Uri handle = request.getAddress(); connection.setAddress(handle, TelecomManager.PRESENTATION_ALLOWED); connection.setRinging(); addCall(connection); return connection; } @Override public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest originalRequest) { Uri handle = originalRequest.getAddress(); TekVConnection connection = new TekVConnection(false, originalRequest,this); connection.setAddress(handle, TelecomManager.PRESENTATION_ALLOWED); connection.setAddress(originalRequest.getAddress(), TelecomManager.PRESENTATION_ALLOWED); connection.setDialing(); connection.setVideoState(originalRequest.getVideoState()); addCall(connection); //setAddress(connection,handle); connection.startOutgoing(); return connection; } @Override public void onCreateIncomingConnectionFailed(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) { // Handle failed incoming connection Log.d(“TekVConnectionService”, “Service created”); } @Override public void onCreateOutgoingConnectionFailed(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) { // Handle failed outgoing connection Log.d(“TekVConnectionService”, “Service created”); } @Override public void onConference(Connection connection1, Connection connection2) { // Handle conference call if needed } private void setAddress(Connection connection, Uri address) { connection.setAddress(address, TelecomManager.PRESENTATION_ALLOWED); if (“5551234”.equals(address.getSchemeSpecificPart())) { connection.setCallerDisplayName(“Hello World”, TelecomManager.PRESENTATION_ALLOWED); } } private void addCall(TekVConnection connection) { mCalls.add(connection); updateConferenceable(); } }` **for PhoneAccount registration,** Below is code for PhoneAccount register ` `@RequiresApi(api = Build.VERSION_CODES.M) private void registerConnectionService() { TelecomManager manager = (TelecomManager) getSystemService(Context.TELECOM_SERVICE); String connectionServiceId = getConnectionServiceId(); ComponentName componentName = new ComponentName(getApplicationContext(), TekVConnectionService.class); PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(componentName, connectionServiceId); phoneAccount = manager.getPhoneAccount(phoneAccountHandle); if (phoneAccount == null) { // no phone account from us registered yet PhoneAccount.Builder builder = PhoneAccount.builder(phoneAccountHandle, getResources().getText(R.string.app_name)); Uri uri = Uri.parse(“tel:987654321”); // builder.setSubscriptionAddress(uri); //builder.setAddress(uri); builder.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER | PhoneAccount.CAPABILITY_CONNECTION_MANAGER); phoneAccount = builder.build(); manager.registerPhoneAccount(phoneAccount); } }“ ` **for Make call,** Below is the code for Making Call private void makeCall(String numberString) { if (hasCallPermission()) { if (phoneAccount != null) { Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL,numberString,null); ComponentName componentName = new ComponentName(getPackageName(), TekVConnectionService.class.getName()); PhoneAccountHandle handle = phoneAccount.getAccountHandle(); Bundle extras = new Bundle(); extras.putParcelable(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, uri); extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, handle); // extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, true); TelecomManager manager = (TelecomManager) getSystemService(Context.TELECOM_SERVICE); manager.placeCall(uri, extras); } } else { requestInCallPermission(); } }