Hello I am working on updating my app compatibility to android 10 and 11 , previously I was making my app to default sms app and receiving and sending new sms from my application , The intent to change default sms app works fine below android 10 but its not showing to change default sms app pop up on android 10
val intent = Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT)
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, packageName)
startActivity(intent)
If anyone know what has changed for android 10 please suggest , because I am not able to find any change for this on developer.android.com , Thanks in advance
After reading documentation carefully , I got they have updated direct intent with RoleManager
,
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
val roleManager = getSystemService(RoleManager::class.java)
val roleRequestIntent = roleManager.createRequestRoleIntent(RoleManager.ROLE_SMS)
startActivityForResult(roleRequestIntent, 12)
} else {
val intent = Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT)
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, packageName)
startActivity(intent)
}
This is new way updating all required access for reference :- https://developer.android.com/reference/android/app/role/RoleManager