diff --git a/CHANGELOG.md b/CHANGELOG.md index f81ea977..abc8a86b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Next release * Fix: [Web] Multiple missed call notifications +* Fix: [Android] `openPhoneAccountsSettings` not always opening on various Android (mainly Samsung) devices ## 0.1.0 diff --git a/android/src/main/kotlin/com/twilio/twilio_voice/types/TelecomManagerExtension.kt b/android/src/main/kotlin/com/twilio/twilio_voice/types/TelecomManagerExtension.kt index 08481346..76f251c5 100644 --- a/android/src/main/kotlin/com/twilio/twilio_voice/types/TelecomManagerExtension.kt +++ b/android/src/main/kotlin/com/twilio/twilio_voice/types/TelecomManagerExtension.kt @@ -61,13 +61,22 @@ object TelecomManagerExtension { fun TelecomManager.openPhoneAccountSettings(activity: Activity) { if (Build.MANUFACTURER.equals("Samsung", ignoreCase = true)) { - val intent = Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS) - intent.component = ComponentName( - "com.android.server.telecom", - "com.android.server.telecom.settings.EnableAccountPreferenceActivity" - ) - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK - activity.startActivity(intent, null) + try { + val intent = Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS) + intent.component = ComponentName( + "com.android.server.telecom", + "com.android.server.telecom.settings.EnableAccountPreferenceActivity" + ) + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK + activity.startActivity(intent, null) + } catch (e: Exception) { + Log.e("TelecomManager", "openPhoneAccountSettings: ${e.message}") + + // use fallback method + val intent = Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS) + activity.startActivity(intent, null) + } + } else { val intent = Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS) activity.startActivity(intent, null)