title: Error in phonegap plugin for changing the screen orientation
body: <p>I am getting this error .</p>
  
  <blockquote>
    <p>Uncaught TypeError: Object # has no method 'exec' at file:///android_asset/www/JS/pg-plugin-screen-orientation.js:4</p>
  </blockquote>
  
  <pre><code>var screenOrientation = function() {}
  
  screenOrientation.prototype.set  = function(str, success, fail) {
  
   PhoneGap.exec(success, fail, "ScreenOrientation", "set", [str]); // GETTING ERROR IN THIS LINE
  
  };
  
  navigator.screenOrientation = new screenOrientation();
  </code></pre>
  
  <p>I have followed the  steps given in this document.
  <a href="https://github.com/champierre/pg-plugin-screen-orientation" rel="nofollow">https://github.com/champierre/pg-plugin-screen-orientation</a> </p>
  
  <hr>
  
  <p>Now it is working fine . But the application crashes when this line  got executed</p>
  
  <pre><code>activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 
  </code></pre>
  
  <hr>
  
  <pre><code>07-24 18:01:19.200: E/AndroidRuntime(12001): FATAL EXCEPTION: main
  07-24 18:01:19.200: E/AndroidRuntime(12001): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@4054e820 is not valid; is your activity running?
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at android.view.ViewRoot.setView(ViewRoot.java:527)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at android.view.Window$LocalWindowManager.addView(Window.java:424)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at android.app.Dialog.show(Dialog.java:241)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at org.apache.cordova.Notification$1.run(Notification.java:205)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at android.app.Activity.runOnUiThread(Activity.java:3717)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at org.apache.cordova.Notification.alert(Notification.java:208)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at org.apache.cordova.Notification.execute(Notification.java:70)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at org.apache.cordova.api.PluginManager.exec(PluginManager.java:212)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at org.apache.cordova.CordovaChromeClient.onJsPrompt(CordovaChromeClient.java:185)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:566)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at android.os.Handler.dispatchMessage(Handler.java:99)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at android.os.Looper.loop(Looper.java:123)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at android.app.ActivityThread.main(ActivityThread.java:3683)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at java.lang.reflect.Method.invokeNative(Native Method)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at java.lang.reflect.Method.invoke(Method.java:507)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  07-24 18:01:19.200: E/AndroidRuntime(12001):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>