在Android中处理浏览器POST的结果的MIME类型[英] Handling MIME type that is the result of a browser POST in Android

本文是小编为大家收集整理的关于在Android中处理浏览器POST的结果的MIME类型的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我有一项活动,该活动已成功调用我感兴趣的MIME类型.从服务器发送的内容是帖子结果创建的XML文档.我试图处理结果两种不同的方式,但我都没有运气:

  1. android:mimeType =" application/customapp" 这样做,我的活动运行,但是我从intent.getdata()获得的URI是用于帖子的URL.致电getContentResolver().openInputStream()在 java.io.filenotfoundexception中导致:没有内容提供商:http://http://em>显然,我只是击中url时,我不会正常工作. t有发布的数据.
  2. android:pathpattern =".*\ custom.app" url的最后一段是custom.app,所以我尝试使用路径模式使用它.这样,浏览器尝试下载文档,并发生两件事之一:库存浏览器尝试下载"无题"和失败. Opera下载文档,按照希望的方式命名,并将提出打开文件,但是Opera Mini除了下载文件外什么都不做.

这是我清单的相关部分与:

中的方案
<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".CustomappActivity" android:label="@string/app_name">
        <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="application/customapp" />
            <data android:scheme="http" />
            <data android:scheme="https" />
        </intent-filter>
    </activity>
</application>

我想使用第一个选项,但是即使需要歌剧,也可以忍受第二个选项,但前提是它在两个版本的歌剧中都持续运行.我只是看不到从服务器发送的结果获得输入流的方法.

推荐答案

我会回答自己的问题.显然,我被搞砸了.库存浏览器及其与下载管理器的交互方式存在已知问题.目前,它无法检索由于HTTP帖子而发送的文档.该错误已详细在这里

本文地址:https://www.itbaoku.cn/post/102685.html

问题描述

I have an Activity that is successfully invoked for the MIME type in which I'm interested. The content being sent from the server is an XML document created as the result of a POST. I've tried to process the result two different ways and I'm not having luck with either:

  1. android:mimeType="application/customapp" Doing this, my activity runs, but the URI I get from Intent.getData() is the URL used for the post. A call to getContentResolver().openInputStream() results in java.io.FileNotFoundException: No content provider: http://.... Obviously, just hitting that URL won't work as I don't have the posted data.
  2. android:pathPattern=".*\custom.app" The last segment of the URL is custom.app, so I tried using that with a path pattern. This way, the browser attempts to download the document and one of two things happens: The stock browser attempts to download "untitled" and fails. Opera downloads the document, naming it as hoped, and will offer to open the file, which works, but Opera Mini does nothing but download the file.

Here is the relevant section of my manifest with the scheme in:

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".CustomappActivity" android:label="@string/app_name">
        <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="application/customapp" />
            <data android:scheme="http" />
            <data android:scheme="https" />
        </intent-filter>
    </activity>
</application>

I'd like to use the first option, but could put up with the second even if it required Opera, but only if it worked consistently across both versions of Opera. I just can't see a way to get an input stream for the result being sent from the server.

推荐答案

I'll answer my own question. Apparently, I'm screwed. There is a known issue with the stock browser and the way it interacts with the download manager. At this time, it cannot retrieve documents that are sent as the result of an HTTP POST. The bug is detailed here