You made a connection interface MyJavaScriptInterface
, but you forgot to attach it to the WebView
:
paintView.addJavascriptInterface(new MyJavaScriptInterface(this), "activity");
That is why you are getting activity is not defined
error. activity
object cannot be found by JS
engine.
Here is a small tutorial on that