1

I am using cordova. I want assign cordova webView to native android webView and pass that native webView as parameter.CalledClass.calledMethod((WebView)MainActivity.appWebView);

My MainActivity class: here I am getting cordovaWebView.

public class MainActivity extends CordovaActivity
{
    static CordovaWebView appWebView;
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        // Set by <content src="index.html" /> in config.xml
        loadUrl(launchUrl);
    }

    @Override
    public CordovaWebView makeWebView(){
        appWebView=super.makeWebView();
        return appWebView;
    }

But when I do this it throws classcast exception. Please help. Thanks in advance.

Shantanu Jha
  • 145
  • 1
  • 4
  • 10

1 Answers1

1

CordovaWebView is not a WebView (doesn't inherit from WebView). Try

CalledClass.calledMethod((WebView)MainActivity.appWebView.getView());

instead.

Kris Erickson
  • 33,454
  • 26
  • 120
  • 175
  • After doing this I am getting following error: 10-09 12:22:05.201: E/PluginManager(6805): java.lang.RuntimeException: java.lang.Throwable: A WebView method was called on thread 'JavaBridge'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {1e7c612e} called on Looper (JavaBridge, tid 670) {eda6af}, FYI main Looper is Looper (main, tid 1) {1e7c612e}) – Shantanu Jha Oct 09 '15 at 07:01
  • If your code was accessing UI on a background thread you have to post to the UI thread, see stackoverflow post: http://stackoverflow.com/questions/12850143/android-basics-running-code-in-the-ui-thread – Kris Erickson Oct 09 '15 at 15:44