Android Intent-filter mimetype 和主机/方案

标签 android host intentfilter

我在某些应用程序中看到,当您单击链接时,它会询问您是否要在应用程序中打开它。我在许多帖子中看到您可以执行此操作

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <data android:host="www.ex-ample.com" android:scheme="http" />
</intent-filter>

我没试过,但每个帖子似乎都说它有效。我尝试的是:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <data android:mimeType="vnd.android.cursor.item/vnd.example.crag" />
  <data android:host="www.ex-ample.com" android:scheme="http" />
</intent-filter>

它似乎不起作用,我单击了转到 www.ex-ample.com/test/123 的文本中的链接,它只是在浏览器中打开。

我真的很想知道两件事:

  1. 你能同时使用 mineType 和 host/scheme 属性吗
  2. 你能看出这还有什么问题吗?

最佳答案

can you use a mineType and a host/scheme attribute together

是的,至少根据 the docs on <data> .

can you see anything else wrong with this?

如果http://www.ex-ample.com/test/123不返回 MIME 类型的文档 vnd.android.cursor.item/vnd.example.crag在 HTTP HEAD 请求中,您的 <intent-filter>将不匹配。

关于Android Intent-filter mimetype 和主机/方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11075179/

相关文章:

java - 在Android中创建字节数组的ArrayList

java - 在工作线程上初始化 TextToSpeech 对象

android - 警告/Activity 管理器 (5038) : Permission denied: checkComponentPermission

java - 如何在 Apache HttpClient 4.3+ 中设置默认 HttpHost 目标?

android - 将 Intent 过滤器与 broadcastReceivers Android 一起使用

android - 仅适用于特定 NFC 标签的应用程序

android - WhatsApp 不显示我的电子邮件应用程序 Intent 在 Android 中共享对话

android - 使用 ADT 在 Eclipse 中开发时如何使用 Android 文档?

mysql - 如何解决CentOS中的 "Failed to connect to MySQL Host"错误

http - 如何从网页连接中获取所有 http 主机?