title: Android & PhoneGap -- Error calling method on NPObject
body: <p>I'm trying to set <code>FLAG_SHOW_WHEN_LOCKED</code> in my phonegap app, but only when a certain page is shown. To do so, I have a Java plugin extending from <code>CordovaPlugin</code> with the following code in the <code>execute</code> method:</p>
  
  <pre><code>if (action.equals("showWhenLocked")) {
      boolean showWhenLocked = args.getBoolean(0);
  
      if (showWhenLocked) {
          this.cordova.getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
      } else {
          this.cordova.getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
      }
  
      callbackContext.success();
      return true;
  }
  </code></pre>
  
  <p>It gets called with <code>cordova.exec(null, null, 'MyPluginClass', 'showWhenLocked', [myVar])</code>, but on execution I get the error</p>
  
  <pre><code>Uncaught Error: Error calling method on NPObject. at file:///android_asset/www/cordova-2.2.0.js:984
  </code></pre>
  
  <p>Any ideas what's causing this/what I'm doing wrong and how to fix it? If I set the flag upon creating the activity it works just fine.</p>