Skip to content
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

Camera does not open on android file input with capture attribute. #808

Open
ReneDyhr opened this issue Oct 30, 2020 · 8 comments
Open

Camera does not open on android file input with capture attribute. #808

ReneDyhr opened this issue Oct 30, 2020 · 8 comments

Comments

@ReneDyhr
Copy link

Bug Report

Problem

When I click an file input, it should make me able to use camera as a input.

What is expected to happen?

When I click the file input with capture= attribute, it should open camera.

What does actually happen?

It opens file manager instead.

Information

Just have a normal file input where you can add capture attribute.
It should then open camera up for the user, but it always open the file manager.

This problem only occurs on Android though, iOS works fine.

Environment, Platform, Device

Android

Version information

Cordova: Cordova CLI 10.0.0.
cordova-android "^9.0.0",
cordova-ios "^5.1.1",
cordova-plugin-camera "^4.1.0",
cordova-plugin-device "^1.1.7",
cordova-plugin-file-transfer "^1.7.1",
cordova-plugin-inappbrowser "^4.0.0",
cordova-plugin-migrate-localstorage "0.0.2",
cordova-plugin-wkwebview-engine "^1.2.1",
cordova-plugin-wkwebview-file-xhr "^2.1.4",

@HYPE-Thomas
Copy link

We are having the same issues, with or without the capture attribute. It works in Chrome, but not in IAP.
Any chance that this bug (and the related ones) get fixed?

@ReneDyhr
Copy link
Author

ReneDyhr commented Dec 9, 2020

I've gone the distance and made the change myself. Didn't have the time to wait, so I removed the file manager and replaced with camera instead.

@HYPE-Thomas
Copy link

Hi, could you elaborate a bit more on what you did, and how? That would be great!

@ReneDyhr
Copy link
Author

I can try. I actually took some of the code from the cordova-plugin-camera plugin and updated public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) from src/android/InAppBrowser.java

In the end, I just removed the file manager code out and inserted the new logic. Later on I would love to update it, so both options is possible and maybe make a pull request

@HYPE-Thomas
Copy link

Thank you very much! 👍 I'm afraid we'll have to resort to something like this, too, if it doesn't get fixed by the team.

@ReneDyhr
Copy link
Author

Do you just need the camera or do you want both options and make the user choose between camera and file manager?

@HYPE-Thomas
Copy link

We would need both options, ideally exactly like in a standard browser. Video recording must also be possible.

Delagen added a commit to Delagen/cordova-plugin-inappbrowser that referenced this issue Aug 11, 2021
@anypoint-aus
Copy link

anypoint-aus commented Sep 14, 2021

Thanks for putting this code in it is great I have been trying it. Have noticed when cancelling without choosing a file or taking a photo it crashes the app or stops future files from working. OnActivityResult I put in a check for intent != null on file chooser and made sure the callback was called for the camera even if there was no result to fix this.

Also I needed to put this meta data in for camera to work if anyone else is trying to implement it https://stackoverflow.com/questions/56598480/couldnt-find-meta-data-for-provider-with-authority

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants