I am trying to control the screen timeout from my cordova application. The application plays the video, and when the application plays the video, I want to turn off the screen timeout. While the video is paused or they are doing something else, I want to turn it back on. If I set the KeepScreenOn flag to OnCreate, it works fine, but if I call it from my plugin, nothing changes. I tried both
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
and
this.webView.setKeepScreenOn(true);
Here is my plugin code.
package com.Kidobi.plugins; import org.apache.cordova.api.CallbackContext; import org.apache.cordova.api.CordovaPlugin; import org.json.JSONArray; import org.json.JSONException; import android.view.WindowManager; public class KeepScreenOn extends CordovaPlugin { @Override public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { System.out.println("Im in the plugin"); if (action.equals("KeepScreenOn")) { System.out.println("KeepScreenOn"); this.webView.setKeepScreenOn(true);
android cordova
Leo Aug 23 '13 at 15:36 2013-08-23 15:36
source share