I want to create a plugin that connect to javascript while using cordova for the plugin, this is my javascipt code :
var Brightness = function() {};
Brightness.prototype.brightnessUp = function( success, error )
{
return cordova.exec( success, error, "Brightness", "brightnessUp", [] );
};
and my plugin code :
public PluginResult execute(String action, JSONArray data, String callbackId) {
PluginResult result = null;
if(action.equals(BRIGHTNESS_UP)){
lightUP();
result = new PluginResult(Status.OK);
}
return result;
}
public void lightUP(){
WindowManager.LayoutParams layoutParams = cordova.getActivity().getWindow().getAttributes();
layoutParams.screenBrightness = 1.0f;
cordova.getActivity().getWindow().getAttributes().screenBrightness = 1.0f;
cordova.getActivity().getWindow().setAttributes(layoutParams);
cordova.getActivity().getWindow().addFlags(WindowManager.LayoutParams.SCREEN_BRIGHTNESS_CHANGED);
}
Somehow I don't know why the "setAttributes(layoutParam)" doesn't make any changed to the brightness screen in my application.
Accidentally when I press the home button, and go back to the application, suddenly the screen brightness changed according to the layoutParams.
Is there any solution for this?