Search code examples
androidgoogle-analyticsadbcommand-prompt

Android - ADB Command in Command Prompt (Windows)


I have an ADB command to be executed in Command Prompt. The purpose of this command is to test Google Analytics Campaign Measurement implementation on my app.

Below code is the command:

adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.example.androidapp/.app.service.CustomReceiver --es "referrer" "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"

This command sends broadcast to app, so when I access "referrer" parameter, I could get this string:

"utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"

However, after testing that code, the only value I could get is:

"utm_source=testSource"

Then I remember that "&" character means ESCAPE in Command Prompt. So, I tried to use "^&" instead of "&", but I get this result:

"utm_source=testSource^"

How do I get the full string? Or what should I add to my code?


Solution

  • Escape it with \ instead of ^

    adb is basically executing the command in shell and not in Windows command prompt. ^ escapes the character in Windows command prompt, but in shell, you'll have to use \