[英]How to open my app when I download a file with specific content-type from the browser, on android?
I'd like to open my app when i download a file with specific mimeTipe, for example "application/pdf" using the browser. 当我使用浏览器下载带有特定mimeTipe的文件(例如“ application / pdf”)时,我想打开我的应用程序。 I tried adding this intent-filter in the manifest app but it doesn't work.
我尝试在清单应用程序中添加此intent-filter,但它不起作用。
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/pdf" />
<data android:scheme="https" />
</intent-filter>
Does the android browser send any intent that can help me to do that? Android浏览器是否发送任何可以帮助我做到这一点的意图? I don' want to open my app by clicking on the file, I need to do this reading the GET header response and opening the app according to the Content-Type of the header.
我不想通过单击文件来打开我的应用程序,我需要读取GET标头响应并根据标头的Content-Type打开应用程序。
What you want is called an Intent Filter . 您想要的就是一个Intent Filter 。 You can define a filter by file name, by URL, or by mime type.
您可以按文件名,URL或mime类型定义过滤器。
In your case, Content-Type is a mime type. 在您的情况下,Content-Type是mime类型。 A Mime example might look like this in your
AndroidManifest.xml
: 一个Mime示例在您的
AndroidManifest.xml
可能看起来像这样:
<intent-filter . . . >
<data android:mimeType="video/mpeg" android:scheme="http" . . . />
<data android:mimeType="audio/mpeg" android:scheme="http" . . . />
. . .
</intent-filter>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.