0

just like what phonegap does, we can simply override and handle the android backButton using javascript but in this case i don't use phonegap. is there a way to handle that without phonegap?

Rosdiana
  • 11
  • 1

1 Answers1

-1

You can call javascript inside your onBackPressed() method:

@Override
public void onBackPressed(){
    WebView.loadUrl("javascript: var result = window.YourJSLibrary.callSomeFunction();
    window.JavaCallback.returnResult(result)");
}

for detailed answer check this solution: How to call javascript from Android?

Community
  • 1
  • 1
mlethys
  • 436
  • 9
  • 29
  • i already have a webview which loads the local html page from asset folder so i can't achieve that :( any other solution? – Rosdiana Mar 13 '15 at 08:53