英文:
Change default sms app intent not working on android 10
问题
抱歉,以下是翻译好的部分:
"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"
英文:
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
答案1
得分: 6
阅读文档后,我了解到他们通过 RoleManager
更新了直接意图(direct intent)的方法,
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)
}
这是一种更新所需访问权限的新方式,供参考:
https://developer.android.com/reference/android/app/role/RoleManager
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论