I want to boot the camera from Monaca's input tag.

Asked 2 years ago, Updated 2 years ago, 45 views

We are creating a tool to upload photos selected from the photos taken by calling the camera or Galleria.
I installed it on my smartphone and I am checking the operation, but the behavior of Android is not as good as I expected.

For iPhone, tap the button to display "Take a picture or video", "Photo Library", "Other", and "Cancel".
In the case of Android, the menu "Open Next" appears, and there are "Drive" and "Gallery" but there are no items that can be photographed with a camera.
Also, you cannot select more than one picture even if you press and hold it for a long time.

The plug-in has Camera and Capture enabled.
It is written in HTML as follows.

    input type="file" id="img" accept="image/*; capture=camera"multiple="multiple">

Do I need any other description to behave the same way as the iPhone?

---add ---
Application permission is
on AndroidManifest.xml Add I have confirmed that the app information on the device has "photographing and video".
https://support.google.com/googleplay/answer/6014972?hl=ja

monaca html5

2022-09-29 22:31

2 Answers

I checked the source code (native Android code) of Cordova used in Monaca, and found that the Intent specified in the method called Input [Type="FILE"] (openFileChoozer in SystemWebChromeClient.java and onShowFileChoozer) was

android.intent.action.GET_CONTENT

It seems that the camera cannot be started because it is implemented as (if you want to use the camera, use an int called android.media.action.IMAGE_CAPTURE).

Therefore, if you want to start the camera, you should use the camera plug-in.
In that case, it is not possible to link the image obtained by the camera plug-in to input type="file" as it is, so it would be better if we could deal with it as follows depending on the application.
1. Use the FileTransfer plug-in to send to the server
2. Use the File Plug-in to store images in your device
3. If you want to use Ajax, implement using FormData objects (http://blog.asial.co.jp/1271)


2022-09-29 22:31

The optional capture is in accept, but I wonder if it's like this...

<input type="file" id="img" accept="image/*"capture="camera"multiple="multiple">


2022-09-29 22:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.