36

使用する

$ adb shell am start some://url

Activity Manager を使用して URL を起動できます。ただし、複数の URL パラメーターを含めると、最初のパラメーター以外はすべて取り除かれます。

例:

$ adb shell am start http://www.example.com?param1=1&param2=2

戻り値:

$ Starting: Intent { act=android.intent.action.VIEW dat=http://www.example.com?param1=1 }

アンパサンドが無視された後、param2は何としても消えます。これを防ぐ & のエンコーディング/エスケープ文字があるかどうか疑問に思っています。

4

5 に答える 5

52

エスケープ文字を使用\:

$ adb shell am start "http://www.example.com?param1=1\&param2=2"
于 2012-11-29T06:24:34.580 に答える
17

次の形式が機能するようです。引用符の形式に注意してください' "

$ adb shell am start -d '"http://www.example.com?param1=1&param2=2"'

于 2018-09-26T08:06:42.073 に答える
5

https://code.google.com/p/android/issues/detail?id=76026で追跡できる Android ビルド ツールのバグのため、受け入れられたソリューションは機能しません。回避策は次のとおりです。

echo 'am broadcast -a com.android.vending.INSTALL_REFERRER -n <your package>/<broadcast-receiver> --es "referrer" "utm_source=test_source&utm_medium=test_medium&utm_term=test_term&utm_content=test_content&utm_campaign=test_name";exit'|adb shell

それをgradleに統合するには、commandLineステートメントを使用できます

commandLine "bash","-c","echo ..."
于 2015-04-23T12:53:58.323 に答える
1

私はすでにここに回避策を投稿しています: https://code.google.com/p/android/issues/detail?id=76026

そこで、インストルメンテーションを含むレシピを次に示します。
アクション com.example.action.VIEW をリッスンするインストルメンテーション内に BroadcastReceiver を登録します。

IntentFilter intentFilter = new IntentFilter("com.example.action.VIEW");
intentFilter.addDataScheme("myschema");
intentFilter.addCategory(Intent.CATEGORY_BROWSABLE);
Context.registerReceiver(new MyBroadcastReceiver(), intentFilter);

アンパサンドを %26 に置き換え (任意のものに置き換えることができます)、インテント com.example.action.VIEW を送信します。
インテントを受信すると、BroadcastReceiver は %26 をアンパサンドに変換し、必要なアクションを含む新しいインテントをアプリに送信します。

public final void onReceive(final Context context, final Intent intent) {
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(intent.getDataString().replaceAll("%26", "&")));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

基本的に、BroadcastReceiver プロキシとして機能します。

于 2015-02-20T00:53:12.597 に答える
1

コマンドを引用してam...ください!
次のようなものが機能するはずです (機能しない場合は、二重引用符を試してください)。

adb shell 'am start http://www.example.com?param1=1&param2=2'
于 2017-01-24T03:10:24.553 に答える