Reputation: 22138
How to open the default handler page in the android setting via intent? or How we can open directly the default SMS page?
it seems from android Q to upper we can not Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT
Upvotes: 0
Views: 2547
Reputation: 21
Another way with this code to open an intent default app, in this case, I try to set the default launcher app
// dialog set default app
@RequiresApi(Build.VERSION_CODES.Q)
private fun showLauncherSelection() {
val roleManager = this.getSystemService(Context.ROLE_SERVICE)
as RoleManager
if (roleManager.isRoleAvailable(RoleManager.ROLE_HOME) &&
!roleManager.isRoleHeld(RoleManager.ROLE_HOME)
) {
val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_HOME)
startActivityForResult(intent,0)
}
}
You can set the other Default app with change the ROLE_HOME
following this Role Manager. If you want to change SMS default app, try to change the ROLE_HOME
to ROLE_SMS
Upvotes: 2
Reputation: 22138
Found the answer, you can open this page by this code:
//This code will work only on android version N and above
//Add if condition to prevent crash on older devices
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Intent intent = new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (requestCode != -1)
act.startActivityForResult(intent, requestCode);
else
act.startActivity(intent);
}
Upvotes: 5