[英]How to open android default apps activity in setting via Intent?
How to open the default handler page in the android setting via intent?如何通过 Intent 打开 android 设置中的默认处理程序页面? 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
似乎从 android Q 到上层我们不能
Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT
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 .您可以在此Role Manager之后更改
ROLE_HOME
来设置其他默认应用程序。 If you want to change SMS default app, try to change the ROLE_HOME
to ROLE_SMS
如果要更改短信默认应用,请尝试将
ROLE_HOME
更改为ROLE_SMS
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.