Cordova - Unable to trigger Android to let me choose an image to upload

限于喜欢 提交于 2019-12-17 21:29:08

问题


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).

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

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 }

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.

How can I solve?

  • Do I need to grant additional permissions? I already added the following:
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
  • 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:*"/>
  • Do I need to install an additional Cordova plugin?

回答1:


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

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



来源:https://stackoverflow.com/questions/54857558/cordova-unable-to-trigger-android-to-let-me-choose-an-image-to-upload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!