0

I am developing an android app using phonegap/cordova 2.0.0.

As of right now, I have a website hosted on my server and my android app is just being used as a wrapper webView.

Here's the code in my java file.

@Override
public void onCreate(Bundle savedInstanceState) {        
    super.onCreate(savedInstanceState);
    webview = new WebView(this);

    webview.getSettings().setJavaScriptEnabled(true);

    webview.getSettings().setPluginsEnabled(true);
    webview.addJavascriptInterface(new JavaScriptInterface(), "jsinterface");

    setContentView(webview);

    // This is where I load the URL of my website
    webview.loadUrl("http://192.168.0.109:3000/");  
}

When I deploy the app to an android phone, it works perfectly fine, I am able to see my website in the phone.

The problem I am facing now is to use phonegap plugin especially ChildBrowser (other plugins give me the same result). I have this exception that is being thrown on my javascript console:

window.plugins.childBrowser.showWebPage("http://www.example.com")
TypeError: Object #<an Object> has no method 'exec'

I followed the instructions on how to use the plugin ChildBrowser Plugin

I have included the javascript files on my website hosted on my server

<script src="/assets/cordova-2.0.0.js" type="text/javascript"></script>
<script src="/assets/childbrowser.js" type="text/javascript"></script>

I have spent days trying to figure that out and googled everything I could try. But no luck for me since none of the solutions has worked for me. I tried the deviceready option but it didn't work:

document.addEventListener("deviceready", yourCallbackFunction, false);

Does anybody have a solution for that or is it even possible to call phonegap plugins from an external website?

PS: I have a working example of ChildBrowser but my android app is reading from

super.loadUrl("file:///android_asset/www/index.html");
Hengh
  • 1
  • 1
  • 1
    are you calling the "window.plugins..." function after deviceReady Event has fired? – 最白目 Sep 02 '12 at 17:35
  • I`m just thinking: Can the page on the web server know what`s inside the android application`s assets folder? I think no but I`m not sure. – 最白目 Sep 02 '12 at 17:37
  • Yes I did try with the deviceready listener. But it is not working for my case. It works well if my app reads from the android application assets folder but when I load the app from my url, it does not work. – Hengh Sep 05 '12 at 01:01
  • yes that makes sense because the remote server doesnt know Phonegap, it`s inside your android assets folder. So he can´t fire deviceready. Or am I missing out on something? – 最白目 Sep 05 '12 at 05:32
  • You are correct the remote server doesn't know phonegap but I have added cordova.js and childbrowser.js on that remote server hoping that it will make it work. Do you know if it's possible to use phonegap plugins this way? – Hengh Sep 05 '12 at 17:32
  • try this, I think it could help you. [Phonegap: Loading remote HTML][1] [1]: http://stackoverflow.com/questions/10470380/phonegap-loading-remote-html – 最白目 Sep 06 '12 at 05:25
  • I finally got it to work. Thank you very much. That link you pasted put me on the right track. I also needed to add my url in the config xml and voila ! – Hengh Sep 10 '12 at 19:03

0 Answers0