diff --git a/app/build.gradle b/app/build.gradle index bcdd855a..b823d54a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -56,7 +56,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.25.19' + implementation 'com.simplemobiletools:commons:5.25.21' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4' implementation 'org.greenrobot:eventbus:3.2.0' implementation 'com.klinkerapps:android-smsmms:5.2.6' diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt index 42bacce7..4e9ae074 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt @@ -48,11 +48,16 @@ class MainActivity : SimpleActivity() { if (isQPlus()) { val roleManager = getSystemService(RoleManager::class.java) - if (roleManager!!.isRoleHeld(RoleManager.ROLE_SMS)) { - askPermissions() + if (roleManager!!.isRoleAvailable(RoleManager.ROLE_SMS)) { + if (roleManager.isRoleHeld(RoleManager.ROLE_SMS)) { + askPermissions() + } else { + val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_SMS) + startActivityForResult(intent, MAKE_DEFAULT_APP_REQUEST) + } } else { - val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_SMS) - startActivityForResult(intent, MAKE_DEFAULT_APP_REQUEST) + toast(R.string.unknown_error_occurred) + finish() } } else { if (Telephony.Sms.getDefaultSmsPackage(this) == packageName) {