Krzychu Krzychu - 1 year ago 71
Android Question

Android WebView: call activity methods form JavaScript interface

Is is possible to call main activity's methods from the JavaScript interface of a WebView object? Or to access SharedPreferences from this interface so I could read the data with my activity? I would like to let my Activity know that a specific JavaScript action occured.

Answer Source

Yes, two way communication between JavaScript and your application is possible through WebView.addJavascriptInterface(). Check this example: