The code is working on emulator but not working on real device.
classJavaScriptInterface{
private TextView contentView;
public JavaScriptInterface(TextView aContentView){
contentView = aContentView;
}
@SuppressWarnings("unused")
public void processContent(String aContent){
final String content = aContent;
contentView.post(new Runnable(){
public void run(){
contentView.setText(content);
contentView.setTextColor(Color.DKGRAY);
}
});
}
}
TextView tv2 = (TextView) findViewById(R.id.source);
webview1.addJavascriptInterface(new JavaScriptInterface(tv2), "INTERFACE");
webview1.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url)
{
view.loadUrl("javascript:window.INTERFACE.processContent(document.getElementsByTagName('body')[0].innerText);");
}
});