cordova - Android DroidGap disabling back button -


please, suggest, how can disable button press event while working phonegap?

i need in activity, (droidgap code) controlling button event.

even, following code works in activity, not working when being used droidgap.

@override public boolean onkeydown(int keycode, keyevent event) {      if (keycode == keyevent.keycode_back) {          //preventing default implementation previous android.os.build.version_codes.eclair          return true;      }      return super.onkeydown(keycode, event);     } 

calling setonkeylistener on appview helped me out.

i had make minor change in above code snippet, follows:

appview.setonkeylistener(new onkeylistener() {      public boolean onkey(view v, int keycode, keyevent event) {         if (keycode == keyevent.keycode_back) {             return true;         }         return onkeydown(keycode, event);      }  }); 

edited

there occurs 2 actions while key-pressing event - action up & action down

so, following should used in order key event.

appview.setonkeylistener(new onkeylistener() {      public boolean onkey(view v, int keycode, keyevent event) {         if (keycode == keyevent.keycode_back && event.getaction() == keyevent.action_up) {             // here whatever want              return true;         }         return onkeydown(keycode, event);      }  }); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -