【问题标题】:Android implicit Intent chooser to display Activities that are capable of viewing URLsAndroid 隐式 Intent 选择器,用于显示能够查看 URL 的活动
【发布时间】:2015-04-27 05:24:07
【问题描述】:

我正在尝试创建一个选择器意图来显示能够查看 URL 的活动。第一个活动应该是 Web 浏览器,第二个活动应该是我创建的自定义活动,称为“MyBrowser”。

当我运行代码时,没有任何活动符合我的意图。以下是我如何称呼隐式意图:

Intent baseIntent = new Intent(Intent.ACTION_SEND, Uri.parse(URL));
Intent chooserIntent = Intent.createChooser(baseIntent, CHOOSER_TEXT);
if (baseIntent.resolveActivity(getPackageManager()) != null) {
            startActivity(chooserIntent);
}

这是我的自定义浏览器活动的意图过滤器:

<intent-filter>
       <action android:name="android.intent.action.VIEW" />
       <category android:name="android.intent.category.DEFAULT" />
       <data android:scheme="http" />
</intent-filter>

【问题讨论】:

  • 尝试将mimeType 添加到您的&lt;data /&gt; 标签blog.blundell-apps.com/add-your-app-to-the-android-menu
  • 查看时应使用 ACTION_VIEW,而不是 ACTION_SEND
  • 嗨,ACTION_VIEW 会打开网络浏览器,但不允许我选择处理 URL 的应用程序。
  • 你是对的,它必须是 ACTION_VIEW。发现我没有正确注册BrowserApp。

标签: android android-intent


【解决方案1】:

我认为浏览网页应该是Intent.ACTION_VIEW 而不是Intent.ACTION_SEND

http://developer.android.com/reference/android/content/Intent.html#ACTION_VIEW

【讨论】:

  • ACTION_VIEW 直接打开网络浏览器,它不允许我选择另一个应用程序来处理 URL。
  • 当你安装了两个浏览器时会发生什么。
  • 你是对的,它必须是 ACTION_VIEW。发现我没有正确注册BrowserApp。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-09
  • 1970-01-01
  • 1970-01-01
  • 2017-01-26
  • 2020-12-22
  • 1970-01-01
相关资源
最近更新 更多