Understanding Android webview javascript interface
<p>I have created an android <code>WebView</code>, and injected <code>javascript</code> interface using <code>addJavascriptInterface(mObject, "jsinterface")</code>. It works fine until I create an object with same name (jsinterface) in JavaScript using the <code>new</code> operator.</p>

<h1>My Java Code:</h1>

<pre><code>WebView mWebView = findViewById(R.id.myWebView);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebChromeClient(new MyWebChromeClient((Activity)mContext));
mWebView.addJavascriptInterface(new testClass(), "jsinterface");
mWebView.loadUrl("UrlToLoad");
</code></pre>

<h2>testClass.java</h2>

<pre><code>public class testClass{
    public testClass() {
    }

    @JavascriptInterface
    public String testNativeMethod() {
        return "Java method called!!";
    }
}
</code></pre>

<h1>My Java Script Code</h1>

<h2>test.js</h2>

<pre><code>function test(msg){
    this.message = msg;

    this.testJSMethod = function(){
        return this.message;
    }
}

alert(jsinterface.testNativeMethod()); // prints Java method called!!
jsinterface= new test("JS method called...");
alert(jsinterface.testJSMethod()); // prints JS method called...
alert(jsinterface.testNativeMethod()); // errors "NPMethod called on non- NPObject"
</code></pre>

<h1>Problem:</h1>

<p>Is this possible for a <code>javascript</code> object to have access to both , i.e  <code>javascript</code> methods and native <code>JAVA</code> methods(exposed to it via <code>javascriptinterface</code>) ? Is there any possibility of setting any property to <code>webview</code> OR executing any JS <code>script</code> to get this done?</p>