Krzychu Krzychu - 1 month ago 7
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

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

http://android-developers.blogspot.com/2008/09/using-webviews.html

Comments