Open Android camera without java or cordova js - javascript

Let me explain my architecture - I have a web project in react js, I am using Cordova just as an apk creator by mentioning my website url in the config file. (ie WWW folder of cordova project only contains index.html)
My problem statement is - I am unable to open android camera (file picker works fine).
There is one solution which would work that is to implement camera functionality in java and call it via js.(but i have been limited to not use java).
Is there any alternate solution to this problem?
UPDATE
I tried the plugin inappbrowser (did not work)
I tried crosswalk webview (did not work)

You can do it with pure JS and Image Capture Web API
Here are two examples:
grab-frame-take-photo
imagecapture
If you need native camera HTML5 is enough:
<input type="file" accept="image/*" capture="camera" />

Related

Cordova InAppBrowser how can i get full download support

Currently I’m working on a app with Cordova for Android and IOS. This app opens a website in the in app browser of Cordova. Now I’m trying to get full download support for this website. Direct download links aren’t really a problem like a .pdf but some download links are just JavaScript posts to a download manager on the server. Currently the InAppBrowser doesn’t do anything with it and because it isn’t a link I can’t attach an event.
Does anyone have a idea how I could solve this problem?
I’m currently using the InAppBrowser version 1.7.0 with Cordova 7.0.1

Crosswalk InAppBrowser in Cordova

I am struggling with opening the website inside the Cordova app using the Crosswalk engine. The default InAppBrowser is rendering the page inproperly, because it uses native WebView(which works bad on older phones like Android 4.3). I am trying to use the cordova-plugin-crosswalk-webview and while it seems to render the cordova view with Crosswalk(the navigator.userAgent says so), when I call either window.open or cordova.InAppBrowser(after installing cordova-plugin-inappbrowser) it uses the native WebView.
Is there something special I have to do to make it render that way ? I also tried this package github, but it seems to not be able to allow executing scripts in the inner browser and I need some sort of communication between the Cordova app and the browser page. Maybe there is some other way for making this communication work(the intention is to be able to show barcode scanner when clicking on the button).
Do you have any idea how to solve this issue ? Big thanks !
Try using this:
//config.xml
<allow-navigation href="http://cordova.apache.org/*" />
//code
window.open('http://cordova.apache.org/', '_self');
https://issues.apache.org/jira/browse/CB-9573
Open a website in crosswalk webview

Launch Android phone front camera by HTML5 or JavaScript

I am building a web app which should open the front camera in the phone with Android (version 4.0+) and after taking the picture the app should upload captured image to my own server.
So is it possible to launch Android phone's front camera by any HTML5 tag or JavaScript code?
I know that rear camera is possible to launch with this tag:
<input type="file" accept="image/*;capture=camera">
But how about front camera? Furthermore, is it possible to add fixed size focus frame to the camera view by using HTML5 web app?
For clarity: Web app is simply the website in my case. It is not any Android app written with PhoneGap or something like that.
Use Device Camera without using PhoneGap or Android Native code
As per I understand you don't want to use PhoneGap for the mobile website but you want to use the native camera option.
In this scenario what I can suggest is you can use Bridgeit which can help you to access the native camera option. Click on the link to check for the demo.
It is very simple to use. You need to add a .js file in your HTML page and call the camera method to access the native camera option of the device.
Sample code:
Use the Bridgeit.js in the HTML header...
<script type="text/javascript" src="http://api.bridgeit.mobi/bridgeit/bridgeit.js"></script>
after that you can call the device camera using the following code:
bridgeit.camera( 'myId', callback, {postURL: '/upload'});
For more detail click on Bridgeit.

Input file properties are blank in mobilefirst app

I have a hybrid app in IBM Mobilefirst platform. There is a file upload feature which uses
<input type='file'>. In the javascript code, the file object parameters like file.size are blank when uploaded from mobile device. Working correctly when previewed from desktop browser. Any clue what is wrong?
You do not have access to the filesystem from pure JavaScript in a mobile application, that is why it does not work you.
When you preview your app in a browser, you're in a browser. A desktop browser does have access to the file system and that is why it works for you.
In order to do any operations on the filesystem in a mobile application you need to use native code (which will obviously not work in a desktop browser).
So either you implement custom native classes, or use Cordova APIs.
It sounds like you need to refer to the Cordova File API: http://docs.phonegap.com/en/3.3.0/index.html
Note: Cordova is bundled in a MobileFirst Hybrid application, so you need only to implement the functionality with the provided APIs.

Can I have a directory chooser in an Android application using phonegap?

I know that html/javascript doesn't give a directory chooser for security reasons ,but what if I'm using phonegap to create an android application ,means I will create this application using html and javascript ,I read phonegap file API but I couldn't figure out a way to do that ,is there any example does the same ?? Any help would be really appreciated ...
there is reference link you may get answer
PhoneGap's File API
Mobile File Explorer with PhoneGap/Cordova and

Categories