Software Archive
Read-only legacy content
17061 Discussions

Camera plugin (following example on youtube of geolocation)

Sara_I_
Beginner
802 Views

I am a complete noob.

I am trying to create a camera plugin following this example: https://www.youtube.com/watch?v=nGuHwzqJI2Y, of geolocation.

I've basically done the same, i.e. copy and past the code containing the functions underneath the code for the button, and the part containing the navigator stuff at 'your code goes here'

 

I've tried both seperately in the example here: https://github.com/apache/cordova-plugin-camera,

and when I go to apppreview nothing happens when i press the button,

I have no idea what to do.

Any help greatly appreciated,

 

0 Kudos
6 Replies
Amrita_C_Intel
Employee
802 Views

Hello,

Please build your application using build tab. It has plugin so it cannot be tested by either app preview or emulator. Build the project, email it to yourself and install the project from the link which is in the email.

0 Kudos
Sara_I_
Beginner
802 Views

Amrita C. (Intel) wrote:

Hello,

Please build your application using build tab. It has plugin so it cannot be tested by either app preview or emulator. Build the project, email it to yourself and install the project from the link which is in the email.

Thanks very much for your reply.

Insight of https://software.intel.com/en-us/forums/topic/560058, and other information online, I thought that cordova plugins were included in apppreview, and that it was only third party plugins that you needed to build the app for.

Will build the app and give it a try. 

0 Kudos
Sara_I_1
Beginner
802 Views
Tried, didn't work. And then you just open the app on the device, not using apppreview? ( it seemed to have downloaded fine, nothing happened when I pressed the button, however i was taken to a page of some code whilst it was downloading which included 'failed url'. Oh and I used the build with android option. Thanks in advance.
0 Kudos
Barry_Johnson
New Contributor I
802 Views

Not sure why Amrita gave the advice that was given; it was in error. As you noted, the "included plugins", of which the camera plug-in you referenced, are available via AppPreview for on-device debugging. In the past, there was also some behavior implemented for this in the emulator (i.e. a call to the camera)

I actually just verified it myself as well, invocation of "navigator.camera.getPicture" works just fine in App Preview via USB debugging.

Whatever problem you are having, it is presumably related to how it is being invoked. If you are doing the on-device debugging (i.e. with a device connected via USB to the machine running the XDK, you may be able to use the debugger, or even some console.log messages to see what is or isn't going on).

You might also want to mention what device you are trying to target (iOS or Android EDIT: I see you mention Android in your last comment). My experience is limited, but I have found accessing the iOS camera via the plugin to be less reliable than on Android. Dialing back the desired image quality often seemed to help. However, even on iOS, one could see "something" was happening - it's just that usually the "something" would involve crashing out of the app! :-D

I would first double check the simple explanation for why you're not seeing the camera get triggered, for example adding an "alert" before invoking the camera just to make certain this isn't a simple issue like not having the event handler wired to the button due to a typo somewhere as well as double-checking that the Camera plugin is indeed checked in the included plugins list in your project, just as a sanity check.

0 Kudos
Swati_S_Intel1
Employee
802 Views

@Sara,

As Barry mentioned the camera plugin should work for you on App Preview and with built app. We have a sample camera app under Projects > samples and demo > General > HTML5+Cordova. Please try that and let us know if it does not work with App Preview or on device. In emulator you will be asked select a file when you try to capture an image (for obvious reasons).

Swati

 

0 Kudos
Azouz_Z_
Beginner
802 Views

Hello Sara,

I installed the same application following exactly the youtube video and it works at least on the emulator.

 

0 Kudos
Reply