-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android clicking input type=file brings up system file browser, not camera options #816
Comments
I've added a minimal test case repo here: https://bitbucket.org/alex-crooks/android-file-test/src/master/ |
@alexcroox Technically add an onClick listener to your tag and handle it yourself by using the above API method, that should resolve your issue. I guess |
The implementation of cordova-android/framework/src/org/apache/cordova/engine/SystemWebChromeClient.java Lines 235 to 249 in 2163c8a
|
In XWalk this function got more attention: Unfortunatelly XWalk is not developed anymore so you can either use the last version of XWalk, use the |
I think you can submit a PR if you want to translate the HTML Image element's
|
I currently have the same problem. Is there someone who can extend the function? |
I agree that this is a problem. It should be handled according to the W3C recommendations, like the system browser does. |
This approach works but has limitations. For example, |
Any update on this? |
Hello guys, do you have more updates / insights to fix this problem ? Thanks a lot ! |
This is half related to this issue, let me know if you want me to open another issue. |
Any update on this? |
If anyone is interested I'm using the following workaround that uses angular/ionic directive: |
Any update? |
If some one have any simple solution please share.
won't help in my scenario |
Any update on this issue? |
any solutions? |
what I did (which is still in progress since im learning android Java for this) is to modify the onShowFileChooser() method of "platforms\android\CordovaLib\src\org\apache\cordova\engine\SystemWebChromeClient.java" add import: and changed the method to below:
I still need to figure out how to unbundle the gallery options but atleast it works for now |
@kortgat can you make a pr about it ? |
Unfortunately i still havent finished it to have a robust workin solution but will try to finish it and make a PR when i have some time |
Thanks a lot @kortgat, do you have any idea of the delay about it ? |
we use https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Taking_still_photos as workaround |
Nice, but my problem is something like this should not have to be worked around, especially if you build pwa, android and ios. Im still learning the android functions in java and figuring out how, to do it in the cordova library so I can at least help others. |
@korgat can you review my solution for camera mode when capture flag present on input. I think i try to resolve similar issue. |
You should also check Capacitor PWA plugins, they directly provide UI components to take a picture, cf https://capacitorjs.com/docs/web/pwa-elements. |
SystemWebChromeClient.zip one usefull use case is when generating forms with a tool lik formIO where you dont have control over the generated html it should will also work |
@kortgat it didn't work allowing camera only on |
my input is as follows |
If you don't put a "capture" key, this will even not open the camera on iOS. Check https://w3c.github.io/html-media-capture/#the-capture-attribute, and input behavior with wkwebview andchrome for android. Do you need more details to make the pr ? |
Whats the status of this issue? I thought |
I agree with a lot of people here saying this is something that we probably shouldn't need a workaround for. @kortgat , with regards to changing the Java file, Is there a way I can make sure this happens after every build or |
Hi, you could add a hook after platform add or before build https://cordova.apache.org/docs/en/10.x/guide/appdev/hooks/ and just create a script to copy it from a root folder or so, mine is called hotfixes, I just added my file here that works for me on android incase I made changes to it since last post. |
@kortgat right on, I was able to add the hook, replace the corresponding file with yours and the camera functionality now works as expected with input elements. |
Using @kortgat's hotfix I was able to get the camera to work, however the images were unusually small - I believe that is because the java code is using the picture's thumbnail instead of the actual picture data, however I cannot seem to get the actual picture data to pass. I've documented my research in PR #1385 - I would appreciate anyone's feedback on the issue. |
It's completely baffling how some dark corners of Cordova just don't work as one would expect and get relegated to oblivion for THREE years. Not to mention this is an inconsistency in a platform that is expected to bring consistency to hybrid development - iOS shows a dropdown to select from the library or camera just fine (albeit you need to add "usage descriptions").
Even then, none of the options trigger the default Android camera interface. Using a plugin is not acceptable either, obviously. |
I created a cordova plugin to patch this issue until someone gets around to fixing this in |
Hello i add same code and open camera but after capture photo not working not getting any result. Below is my updated code in inAppBroswe.java file
|
It seems that while it works on a Samsung Galaxy A50 running Android 11, it neither works on any Android simulator SDK version (30-34), nor does it work on Pixel 8 running Android 14. "Doesn't work" means that after taking a photo and ok'ing it, the input change event does not fire. |
Bug Report
Problem
When clicking on an html type="file" input a system file picker appears instead of camera options.
What is expected to happen?
If I perform the same action in the system browser I get the expected dialog:
Version information
cordova-cli 9.0.0
Full test case repo here
Checklist
The text was updated successfully, but these errors were encountered: