无法获得亮度离子cordova-plugin-brightness

时间:2016-08-25 10:36:27

标签: angularjs cordova ionic-framework cordova-plugins brightness

我有从cordova-plugin-brightness获得亮度的问题。 我得到了不明目标的对象。 (我可以设置亮度,但我无法获得亮度)

         var LightControl = cordova.plugins.brightness;

            LightControl.getBrightness();
            console.log("brightness: "+LightControl.getBrightness());

1 个答案:

答案 0 :(得分:0)

根据documentation of this plugin,您需要将函数作为参数传递给getBrightness()函数。

因此,在这种情况下,您的代码看起来像这样:

var LightControl = cordova.plugins.brightness;

LightControl.getBrightness(function(brightness) {
  console.log("The current brightness is: " + brightness);
}, function(error) {
  console.log("Error: " + error);
});