Take a look at this, the explicit and implicit intent sections (1.2, 1.3):
http://www.vogella.de/articles/AndroidIntent/article.html
Then take a look at the source code for WebIntent.java, in particular the startActivity function:
https://github.com/phonegap/phonegap-plugins/blob/master/Android/WebIntent/WebIntent.java
void startActivity(String action, Uri uri, String type, Map<String, String> extras) {
Intent i = (uri != null ? new Intent(action, uri) : new Intent(action));
And then the intent constructors here (search for Constructors):
http://developer.android.com/reference/android/content/Intent.html
WebIntent does not support the Intent constructor that that takes an Android class.
But you can extend the function to have it work with an explicit intent (code below is quick and dirty and untested):
void startActivity(String action, Uri uri, String type, String className, Map<String, String> extras) {
Intent i;
if (uri != null)
i = new Intent(action, uri)
else if (className != null)
i = new Intent(this.ctx, Class.forName(className));
else
new Intent(action));
Above, in the execute function, you must also parse out the new parameter in the "Parse the arguments" section
// Parse the arguments
JSONObject obj = args.getJSONObject(0);
String type = obj.has("type") ? obj.getString("type") : null;
Uri uri = obj.has("url") ? Uri.parse(obj.getString("url")) : null;
String className = obj.has("className") ? obj.getString("className") : null;
JSONObject extras = obj.has("extras") ? obj.getJSONObject("extras") : null;
and then pass the new className string in the call to startActivity a few lines below:
startActivity(obj.getString("action"), uri, type, className, extrasMap);
Then you should be able to call an android activity by classname using something like:
Android.callByClassName = function(className) {
var extras = {};
extras[WebIntent.EXTRA_CUSTOM] = "my_custom";
extras[WebIntent.EXTRA_CUSTOM2] = "my_custom2";
window.plugins.webintent.startActivity({
className: className,
extras: extras
},
function() {},
function() {
alert('Failed to send call class by classname');
}
);
};
Where the classname is something like: com.company.ActivityName
DISCLAIMER: Rough code, not tested.