首页 > 解决方案 > 在 Android 应用中,如何忽略默认的应用偏好并强制用户选择应用?

问题描述

当我让用户在浏览器中打开一个链接时,我可以强制用户从他们可用的浏览器中进行选择,而不使用他们的默认浏览器吗?

标签: javaandroid

解决方案


尝试这个:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));

String title = "Select a browser";
Intent chooser = Intent.createChooser(intent, title);

if (intent.resolveActivity(getPackageManager()) != null) {
    startActivity(chooser);
}

推荐阅读