简体   繁体   English

在Android上从浏览器下载具有特定内容类型的文件时,如何打开我的应用程序?

[英]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.

相关问题 在浏览器中下载链接/如果标题中有特殊的Content-Type,请打开我的活动 - Download link in browser / Open my activity if there is a special Content-Type in the Header 尝试从我的应用程序打开 web 浏览器时看到“android.content.ActivityNotFoundException” - I'm seeing an `android.content.ActivityNotFoundException` when trying to open a web browser from my app Android AsyncHttpClient下载包含Content-Type:unkonwn标头的图像文件 - Android AsyncHttpClient download image file with Content-Type: unkonwn header 如何从Android应用程序打开特定的浏览器 - How to open a specific browser from an android app 如何在浏览器中打开rss链接时打开我的Android应用程序? - How to open my Android app when rss link is opened in browser? Android:如何强制将文件下载(从Chrome,Gmail…)到我的应用定义的特定位置 - Android: how do I force file download (form Chrome, Gmail…) to a specific location defined by my app Android WebView:当内容类型为 application/pdf 时下载,如果不是则呈现网页 - Android WebView: Download when content-type is application/pdf and render web page if not 如何从具有内容URI的云中下载我的应用程序中的文件 - How to download a file in my app from a cloud with a content URI Android-如何从浏览器打开我的应用 - Android-How to open my app from the browser 当我下载附件时如何阅读我的应用程序需要识别我在android中的自定义扩展名文件 - How to read when i download that attachment my app need to recognize my custom extension file in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM