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);
}
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.