From 4800ac3573e6be8b9f2cc18b5d802c0c8a2e0117 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 28 Nov 2018 14:01:37 +0100 Subject: [PATCH] adding some outgoing call related things --- .../contacts/pro/activities/DialerActivity.kt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/DialerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/DialerActivity.kt index 15fb5765..ffe521f3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/DialerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/DialerActivity.kt @@ -137,11 +137,22 @@ class DialerActivity : SimpleActivity(), SensorEventListener { dialer_label.setText(if (isIncomingCall) R.string.incoming_call_from else R.string.calling) } + @SuppressLint("MissingPermission") private fun initOutgoingCall() { - val telecomManager = getSystemService(Context.TELECOM_SERVICE) as TelecomManager - val uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, callNumber, null) - val extras = Bundle() - telecomManager.placeCall(uri, extras) + try { + val telecomManager = getSystemService(Context.TELECOM_SERVICE) as TelecomManager + val uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, callNumber, null) + Bundle().apply { + putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, telecomManager.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL)) + putBoolean(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, false) + putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false) + telecomManager.placeCall(uri, this) + } + callStatus = Call.STATE_DIALING + } catch (e: Exception) { + showErrorToast(e) + finish() + } } private fun startNotificationService() {