Cordova-无法触发Android让我选择要上传的图片 [英] Cordova - Unable to trigger Android to let me choose an image to upload

查看:84
本文介绍了Cordova-无法触发Android让我选择要上传的图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Cordova包装第三方iframe.在iframe中,有一个上传按钮. 它可在iOS上运行,我可以选择要上传的照片(请参见下面的屏幕截图).

I am using Cordova to wrap a third party iframe. In the iframe there is an upload button. It works on iOS, I am able to select a photo to upload (see screenshot below).

在Android上,但是当我单击上传按钮时,没有任何反应,该按钮会提示用户打开图库以选择文件.

On Android though nothing happens when I click the upload button that should prompt the user to open the gallery to select a file.

控制台中没有错误,但我在LogCat中发现此错误: No activity found to handle file chooser intent: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT cat=[android.intent.category.OPENABLE] typ=.jpg,.png,.tiff,.jpeg,.tif,.pdf }

There are no errors in the console but I found this error in LogCat: No activity found to handle file chooser intent: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT cat=[android.intent.category.OPENABLE] typ=.jpg,.png,.tiff,.jpeg,.tif,.pdf }

该错误告诉我该设备未安装任何应用程序能够处理特定的隐式意图.但是为什么它不能使用默认的照片"或文件"应用程序?当我尝试使用移动浏览器上传图像时,Files App会正确显示.

That error tells me that the device has no applications installed that are able to handle that particular implicit intent. But why can't it use the default Photos or Files App? When I try to upload an image using a mobile browser the Files App correctly shows up.

我该如何解决?

  • 我需要授予其他权限吗?我已经添加了以下内容:
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />

  • 我是否在config.xml中缺少特定的允许意图? 我当前的设置是这些:
    • Am I missing a specific allow-intent in my config.xml? My current settings are these:
    •   <allow-intent href="https://*.mydomain.com.*"/>
        <allow-intent href="tel:*"/>
        <allow-intent href="sms:*"/>
        <allow-intent href="mailto:*"/>
        <allow-intent href="geo:*"/>
      

      • 我需要安装其他的Cordova插件吗?
      • 推荐答案

        进一步调查后,我意识到这不是权限问题.

        After further investigation I realized that it's not a permissions issue.

        当我手动将第三方上传按钮HTML更改为<input type="file" />时,它可以工作.

        It works when I manually change the third party upload button HTML to <input type="file" />.

        这篇关于Cordova-无法触发Android让我选择要上传的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆