check if the SMS Role exists before relying on it
This commit is contained in:
parent
a91c8d7334
commit
fb5f67d5b6
|
@ -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'
|
||||
|
|
|
@ -48,12 +48,17 @@ class MainActivity : SimpleActivity() {
|
|||
|
||||
if (isQPlus()) {
|
||||
val roleManager = getSystemService(RoleManager::class.java)
|
||||
if (roleManager!!.isRoleHeld(RoleManager.ROLE_SMS)) {
|
||||
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 {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
finish()
|
||||
}
|
||||
} else {
|
||||
if (Telephony.Sms.getDefaultSmsPackage(this) == packageName) {
|
||||
askPermissions()
|
||||
|
|
Loading…
Reference in New Issue