简体   繁体   English

(cordova 4.3.0)Flashlight插件不起作用,控制台未引发任何错误

[英](cordova 4.3.0) Flashlight plugin doesn't work , no errors are throwed in console

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 . 即时通讯使用ubuntu 12.04和cordova 4.3.0和Flashlight插件,试图在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 : 但是当我打开应用程序时,什么也没发生,请打开Chrome开发者工具以查看控制台中的错误,但未显示任何错误...这是我的代码:

    <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? 您是否已将插件xml添加到config.xml中? If not add it. 如果没有添加。

Ex: xmlns:gap="http://phonegap.com/ns/1.0" //add this is widget tag 例如:xmlns:gap =“ http://phonegap.com/ns/1.0” //添加这是小部件标签

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM