Category Archives: android-camera

Cordova camera plugin not working in android mobile but working in emulator

I have developed an app to test the camera open in android mobiles, I have followed the cordova camera API document, My code works fine and perfect in emulator, but not opening when i opens the camera in mobile,

Here is my code: config.xml

<?xml version="1.0" encoding="utf-8"?>
<widget xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps" id="io.cordova.CameraTest" version="1.0.0" xmlns="http://www.w3.org/ns/widgets">
  <name>CameraTest</name>
  <description>A blank project that uses Apache Cordova to help you build an app that targets multiple mobile platforms: Android, iOS, Windows, and Windows Phone.</description>
  <author href="http://cordova.io" email="[email protected]">Apache Cordova Team </author>
  <content src="index.html" />
  <access origin="*" />
  <preference name="SplashScreen" value="screen" />
  <preference name="windows-target-version" value="8.0" />
  <preference name="windows-phone-target-version" value="8.1" />
  <vs:plugin name="org.apache.cordova.camera" version="0.3.2" />
  <vs:plugin name="org.apache.cordova.dialogs" version="0.2.10" />
  <feature name="http://api.phonegap.com/1.0/device" />
<feature name="http://api.phonegap.com/1.0/camera"/>
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/media"/>
<feature name="http://api.phonegap.com/1.0/network"/>
  <vs:platformSpecificValues />
</widget>

Js code:

document.addEventListener( 'deviceready', onDeviceReady.bind( this ), false );

    function onDeviceReady() {
        // Handle the Cordova pause and resume events
        pictureSource = navigator.camera.PictureSourceType;
        destinationType = navigator.camera.DestinationType;
        document.addEventListener( 'pause', onPause.bind( this ), false );
        document.addEventListener( 'resume', onResume.bind( this ), false );

        // TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.
    };

script:

    <script src="cordova.js"></script>
<script>
         var pictureSource;
                var destinationType;
                function opencam() {

                    navigator.camera.getPicture(onsucess, onfail, {
                        quality: 50,
                        destinationType: destinationType.DATA_URL,
                        allowEdit: true,
                        targetWidth: 100,
                        targetHeight: 100,
                        saveToPhotoAlbum: false
                    });
                }

                function onsucess(imageData) {

                    debugger;
                }
                function onfail(message) {
                    alert("Error: " + message);
                    debugger;
                }
</script>

Its working fine in ripple emulator, but when i install in mobile, camera is opening at all..

Note: I don't have androidmanifest.xml file in my solution

Please help me urgent!!