Check out the explicit and implicit intent sections (1.2, 1.3) here:
Next, review the source code for WebIntent.java, specifically focusing on 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));
Also, explore the intent constructors available by searching for Constructors here:
http://developer.android.com/reference/android/content/Intent.html
WebIntent does not currently support the Intent constructor that includes an Android class.
However, you can modify the function to work with an explicit intent using the following untested code snippet:
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));
In the execute function, ensure to parse out the new parameter in the "Parse the arguments" section as well:
// 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;
Then pass the new className string in the call to startActivity a few lines below like this:
startActivity(obj.getString("action"), uri, type, className, extrasMap);
Once done, you should be able to invoke an android activity through classname using a structure similar to:
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');
}
);
};
Make sure the classname follows a format such as: com.company.ActivityName
DISCLAIMER: Code is raw and needs testing.