これを見て、明示的および暗黙的意思のセクション(1.2、1.3): https://github.com/phonegap/phonegap-plugins/blob/master/Android/WebIntent/WebIntent.java
:
http://www.vogella.de/articles/AndroidIntent/article.html
は、その後、特に、startActivity機能を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));
そして、ここに、その後の意図コンストラクタ(コンストラクタを検索): http://developer.android.com/reference/android/content/Intent.html
WebIntentは、Androidクラスを取るインテントコンストラクタをサポートしていません。
しかし、あなたはそれが(次のコードは、迅速かつ汚いと未検証です)明示的な意図を持って仕事持っている機能を拡張することができます、上記
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));
実行機能で、あなたも新しいを解析しなければなりません
startActivity(obj.getString("action"), uri, type, className, extrasMap);
012:「引数を解析」セクションのパラメータ
// 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;
、その後はstartActivityへの呼び出し以下の数行の新しいクラス名の文字列を渡します
次に、あなたのようなもの使っclassnameでアンドロイドアクティビティを呼び出すことができる必要があります:
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');
}
);
を};
クラス名のようなものである
:com.company.ActivityName
免責事項:ラフコード、テストされていません。
はあなたが放送されているインテントをリッスンする必要があると言っていますか? –
いいえ、その逆です。私はPhoneGapの中に包まれたものからインテントを放送したい。 – Mitraidos