Call javascript function from Java

前端 未结 2 1112
悲&欢浪女
悲&欢浪女 2021-01-20 07:13

I develop an app using PhoneGap. I got a service which is in background and is coded natively (the service and the phone gap app is in the same project). Unfortunatly, I wan

2条回答
  •  天涯浪人
    2021-01-20 08:09

    You cant call object.loadUrl("javascript:function();"); from the plugin as plugin doesnt extend the WebView of Android. To call loadUrl you would have to pass the call back to the Home class which extends DroidGap.

    In the plugin you can define

    Home home = null;
    Looper.prepare();
    home = new Home();
    home.somefunc();
    

    and in somefunc call

    super.loadUrl("javascript:function();");
    

提交回复
热议问题