Skip to content

Commit 470cea6

Browse files
authored
Merge pull request #172 from cybex-dev/fix_open_calling_account_settings
Fix `openPhoneAccountSettings` on Android
2 parents 784d0b5 + bdd239f commit 470cea6

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Next release
22

33
* Fix: [Web] Multiple missed call notifications
4+
* Fix: [Android] `openPhoneAccountsSettings` not always opening on various Android (mainly Samsung) devices
45

56
## 0.1.0
67

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)