Choose camera in file upload in cordova application on android without using cordova camera

前端 未结 6 2081
野趣味
野趣味 2021-01-07 17:01

So i made a cordova app, i added android platform and made a simple html with an imput field



        
6条回答
  •  醉酒成梦
    2021-01-07 17:41

    After a bit of Googling, this is what I could conclude:

    Media capture in mobile browsers still seems to have some issues. Check out this link. The excerpt says:

    Actually, it seems that current implementations don’t rely on the capture attribute at all, but only on the type and accept attributes: the browser displays a dialog box in which the user can choose where the file has to be taken, and the capture attribute is not taken into consideration. For example, iOS Safari relies on the accept attribute (not capture) for images and videos (not audio). Even if you don’t use the accept attribute, the browser will let you choose between “Take Photo or Video” and “Choose Existing”

    So looks like capture attribute does not make any impact.

    Also, suggest you look at this SO post for more info on making this work. Hope it helps. Cheers.

    UPDATE: After downvoting, I dig further deep regarding the issue. Most of the searches resulted in no success as the optimum solution for this issue is to use Cordova camera plugin. Finally stumbled on this SO post which is exactly duplicate of this question. The user was able to resolve the issue (using crosswalk web view, though). The answer in that post is mentioned here already by @Fabio. But instead of adding the plugin just for including the permissions, you can make use of cordova-custom-plugin to add the required permissions.

    Also as per @jcesarmobile's comment (who is a Cordova expert) in the post without crosswalk web view plugin, input type works fine only on iOS and not on Android. So using camera plugin is the only way to make it work without using crosswalk plugin.Hopefully, it helps.

    UPDATE 2: After the updated question, I dug bit more deep for the resolution of this issue. But now I can assure that this issue is still not resolved for Android Webview. Looks like it is not a Cordova issue but issue with Chromium web view.

    For detailed info, request you to please look at these issues in Apache Cordova Issue Tracker:

    • File input element not opening
    • File input element should support accept/source attributes

    Both these issues are unresolved till date. So I m sure that for now, you cannot make it work on Android unless you use Cordova camera plugin. Hope you agree with me and accept the resolution. Cheers

提交回复
热议问题