Skip to content

Commit cbccddf

Browse files
committed
fix: openPhoneAccountSettings using try/catch with fallback
1 parent 784d0b5 commit cbccddf

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

android/src/main/kotlin/com/twilio/twilio_voice/types/TelecomManagerExtension.kt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,22 @@ object TelecomManagerExtension {
6161

6262
fun TelecomManager.openPhoneAccountSettings(activity: Activity) {
6363
if (Build.MANUFACTURER.equals("Samsung", ignoreCase = true)) {
64-
val intent = Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS)
65-
intent.component = ComponentName(
66-
"com.android.server.telecom",
67-
"com.android.server.telecom.settings.EnableAccountPreferenceActivity"
68-
)
69-
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
70-
activity.startActivity(intent, null)
64+
try {
65+
val intent = Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS)
66+
intent.component = ComponentName(
67+
"com.android.server.telecom",
68+
"com.android.server.telecom.settings.EnableAccountPreferenceActivity"
69+
)
70+
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
71+
activity.startActivity(intent, null)
72+
} catch (e: Exception) {
73+
Log.e("TelecomManager", "openPhoneAccountSettings: ${e.message}")
74+
75+
// use fallback method
76+
val intent = Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS)
77+
activity.startActivity(intent, null)
78+
}
79+
7180
} else {
7281
val intent = Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS)
7382
activity.startActivity(intent, null)

0 commit comments

Comments
 (0)