0

I know you can take an instance of a webview and call addJavascriptInterface(new WebAppInterface(context), "nameofinterface") to allow javascript to send data to Android Java code. But how do I go the other way? I want to tell javascript to play a video at a specific point in time when I hit the back button on my android device. Any ideas?

1 Answer 1

1
webView.loadUrl("javascript:function()");

You can put it here:

@Override
public void onBackPressed() {
    // ...
}
Sign up to request clarification or add additional context in comments.

2 Comments

thanks, it'd be nice if Javascript was mentioned in the android documentation with this method.
Afaik, this is also how you do it in most browser scripting languages. A relevant mention in the docs would be nice though

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.