cordova-plugin-inappbrowser icon indicating copy to clipboard operation
cordova-plugin-inappbrowser copied to clipboard

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

Open ReneDyhr opened this issue 4 years ago • 8 comments

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",

ReneDyhr avatar Oct 30 '20 13:10 ReneDyhr

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?

HYPE-Thomas avatar Dec 09 '20 14:12 HYPE-Thomas

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.

ReneDyhr avatar Dec 09 '20 14:12 ReneDyhr

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

HYPE-Thomas avatar Dec 09 '20 14:12 HYPE-Thomas

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

ReneDyhr avatar Dec 10 '20 06:12 ReneDyhr

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.

HYPE-Thomas avatar Dec 10 '20 07:12 HYPE-Thomas

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

ReneDyhr avatar Dec 10 '20 07:12 ReneDyhr

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

HYPE-Thomas avatar Dec 10 '20 07:12 HYPE-Thomas

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

anypoint-aus avatar Sep 14 '21 02:09 anypoint-aus