java - 在 Android 应用中,如何忽略默认的应用偏好并强制用户选择应用?
问题描述
当我让用户在浏览器中打开一个链接时,我可以强制用户从他们可用的浏览器中进行选择,而不使用他们的默认浏览器吗?
解决方案
尝试这个:
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);
}
推荐阅读
- ruby-on-rails-4 - Rails 自定义错误页面工作和不工作
- oracle - 函数中调用过程
- javascript - 如何在 slickgrid 单元格内呈现 angularjs 指令
- cakephp - 在 cakephp 3.x 中使用存储过程
- awk - 如何在同一字段中查找/打印两个相反符号的连续浮点数?
- python - 如何通过 API 从 Telegram 组获取消息 - Python
- memory - 我正在尝试通过很多步骤使用 5 维数组。我收到一个错误:''std::bad_alloc''
- javascript - 需要将元素替换为数组中右侧元素的最大值
- java - 设置后清除工具栏菜单(启动活动时)
- visual-studio - 自动缩进破坏文件的缩进