Using
$ adb shell am start some://url
I can launch URLs using activity manager. However if I include multiple URL parameters, all but the first parameter gets stripped out.
Example:
$ adb shell am start http://www.example.com?param1=1¶m2=2
Returns:
$ Starting: Intent { act=android.intent.action.VIEW dat=http://www.example.com?param1=1 }
and param2 disappears as anything after an ampersand gets ignored. I'm wondering if there's some encoding/escape character for the & that will prevent this.
The accepted solution does not work because of a bug in the android build tools which you can track here: https://code.google.com/p/android/issues/detail?id=76026 . A workaround is the below:
To integrate it in gradle you can use the commandLine statement
Quote the
am...
command!Something like the following should work (if it doesn't, try double-quote):
I have already posted a workaround here: https://code.google.com/p/android/issues/detail?id=76026
So, here is the recipe that involves instrumentation.
Register a BroadcastReceiver within the instrumentation that listens to action com.example.action.VIEW.
Replace ampersand with %26 (use can replace it with anything you want) and send an intent com.example.action.VIEW.
Once received intent BroadcastReceiver converts %26 back to ampersand and sends a new intent with desired action to your app.
Basically it acts as a BroadcastReceiver proxy.
The following format seems to work. Note the quotes format
'
"
:$ adb shell am start -d '"http://www.example.com?param1=1¶m2=2"'
use escape character
\
: