Grofit
Grofit

Reputation: 18465

PhoneGap android application with plugins

This is just something I am going to have to look at shortly so was wanting to get a headstart on the topic.

Currently I have a phonegap application which contains a load of HTML/JS files, as you would expect, however I am also going to want to support plugins. The plugins would contain new html/js files as well as other resources, and would expose a plugin contract model based off some interface. So you would install the main app, then lets say I decided to add a new plugin for X, they would then go to the marketplace and download the plugin app, which by itself is useless, but would be called upon via the main application.

Now after looking through the interwebs I found Write Plugin for Android App

which tells me how to go about loading a plugin at the android level, but the part which confuses me a bit is how can I get access to the html/js resources contained within that plugin. With .net and things you can pull resources from dlls but would I have to do this in Android or is there some nicer way to get access to the static files contained within the addons.

So the crux of this question is, how can I load static files from an installed plugin.

Upvotes: 1

Views: 308

Answers (1)

osayilgan
osayilgan

Reputation: 5893

I'm not sure that I understand your question clearly, but I guess you want to learn how you can trigger a function in your js files. If its the question here how I'm doing it. Hope it helps.

    private static void invokeJavascript(String javascriptFunctionName, String[] javaScriptParam) {

        StringBuilder buf = new StringBuilder("javascript:");

        buf.append(javascriptFunctionName);
        buf.append("('");

        for (int i = 0; i < javaScriptParam.length; i++) {
            buf.append(javaScriptParam[i]);
                buf.append("','");
        }

        buf.append("','nativeCallbackSuccess', 'nativeCallbackFail')");
        cordovaWebView.loadUrl(buf.toString());
  }

Upvotes: 1

Related Questions