How about try to override Activity::dispatchKeyEvent?

From: Crosswalk-help 
[mailto:[email protected]] On Behalf Of 
Daniele Gibertoni
Sent: Tuesday, March 17, 2015 8:16 PM
To: [email protected]
Subject: [Crosswalk-help] shouldOverrideKeyEvent and Back button on embedded 
webview

Hello.
We have an Android app that use an embedded Crosswalk XWalkView (stable version 
11.40.277.7). We would like to disable the default behavior of hardware back 
button (go back on webview history) in order to have it handled by our 
application.
It seems that is not possible to do: the Crosswalk webview will always handles 
the back button press and changes the page.

Our relevant code in XWalkUIClient:

@Override
    public boolean shouldOverrideKeyEvent(XWalkView view,  
android.view.KeyEvent event){
        int keycode=event.getKeyCode();
        if(keycode==KeyEvent.KEYCODE_BACK){
            return true;
        }
        return false;
    }

Our code in main Activity:

public void onBackPressed() {
}

@Override
      public boolean onKeyDown(int keyCode, KeyEvent event){
          if ((keyCode == KeyEvent.KEYCODE_BACK) ) {
              return true;
          }
          return super.onKeyDown(keyCode,event);
      }

We are missing something?
Thank You!

Daniele Gibertoni


_______________________________________________
Crosswalk-help mailing list
[email protected]
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help

Reply via email to