title: force close when clicking the back button in android phonegap app
body: <p>I have created android phonegap app using html,css,javascript and
      jquery.When i hit the back button my app gets force closed.My error in
      the logcat is below:</p>
  
  <pre><code>ERROR/AndroidRuntime(23383): FATAL EXCEPTION: main
      ERROR/AndroidRuntime(23383): android.view.WindowManager
      $BadTokenException: Unable to add window -- token
      android.os.BinderProxy@48c59828 is not valid; is your activity
      running?
      at android.view.ViewRoot.setView(ViewRoot.java:505)
      at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:207)
      at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:121)
      at android.view.Window$LocalWindowManager.addView(Window.java:424)
      at android.app.Dialog.show(Dialog.java:259)
      at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
      at com.phonegap.DroidGap$GapClient.onJsAlert(DroidGap.java:983)
      at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:531)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:123)
      at android.app.ActivityThread.main(ActivityThread.java:4632)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:521)
      at com.android.internal.os.ZygoteInit
      $MethodAndArgsCaller.run(ZygoteInit.java:871)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
      at dalvik.system.NativeStart.main(Native Method)
      ERROR/(1364): Dumpstate &gt; /data/log/dumpstate_app_error
  </code></pre>
  
  <p>Please kindly guide me where i am wrong.Thanks in advance. </p>