Krzychu Krzychu - 2 months ago 14
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.


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