first thing first , sorry for my REALLY BAD ENGLIGH , and my coding skill too i know so many questions say about plugins do not work .... but im bagging my head over more than one week before i decided ask this question .
im using ubuntu 12.04 with cordova 4.3.0 and Flashlight plugin , trying to turn on flashlight in android . but when i the open app, nothing happen , open Chrome Developer Tools to view error in console , but no error is showed ... here is my code :
<body>
<h2 onclick="window.plugins.flashlight.toggle();">Flash light </h2>
<script src='cordova.js'></script>
<script src="js/Flashlight.js"></script>
<script>
document.addEventListener("deviceready",Ondeviceready,false);
function Ondeviceready(){
window.plugins.flashlight.available(function(isAvailable) {
if (isAvailable) {
// switch on
window.plugins.flashlight.switchOn(); // success/error callbacks may be passed
// switch off after 3 seconds
setTimeout(function() {
window.plugins.flashlight.switchOff(); // success/error callbacks may be passed
}, 3000);
} else {
alert("Flashlight not available on this device");
}
});
}
</script>
</body>
Thanks for any answer !
Have you added the plugin xml to the config.xml? If not add it.
Ex: xmlns:gap="http://phonegap.com/ns/1.0" //add this is widget tag
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.