mirror of
				https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
				synced 2025-06-05 21:49:22 +02:00 
			
		
		
		
	check if the SMS Role exists before relying on it
This commit is contained in:
		| @@ -56,7 +56,7 @@ android { | |||||||
| } | } | ||||||
|  |  | ||||||
| dependencies { | dependencies { | ||||||
|     implementation 'com.simplemobiletools:commons:5.25.19' |     implementation 'com.simplemobiletools:commons:5.25.21' | ||||||
|     implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4' |     implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4' | ||||||
|     implementation 'org.greenrobot:eventbus:3.2.0' |     implementation 'org.greenrobot:eventbus:3.2.0' | ||||||
|     implementation 'com.klinkerapps:android-smsmms:5.2.6' |     implementation 'com.klinkerapps:android-smsmms:5.2.6' | ||||||
|   | |||||||
| @@ -48,12 +48,17 @@ class MainActivity : SimpleActivity() { | |||||||
|  |  | ||||||
|         if (isQPlus()) { |         if (isQPlus()) { | ||||||
|             val roleManager = getSystemService(RoleManager::class.java) |             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() |                     askPermissions() | ||||||
|                 } else { |                 } else { | ||||||
|                     val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_SMS) |                     val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_SMS) | ||||||
|                     startActivityForResult(intent, MAKE_DEFAULT_APP_REQUEST) |                     startActivityForResult(intent, MAKE_DEFAULT_APP_REQUEST) | ||||||
|                 } |                 } | ||||||
|  |             } else { | ||||||
|  |                 toast(R.string.unknown_error_occurred) | ||||||
|  |                 finish() | ||||||
|  |             } | ||||||
|         } else { |         } else { | ||||||
|             if (Telephony.Sms.getDefaultSmsPackage(this) == packageName) { |             if (Telephony.Sms.getDefaultSmsPackage(this) == packageName) { | ||||||
|                 askPermissions() |                 askPermissions() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user