Android Intent Data Uri Query Parameter

2019-04-04 15:15发布

问题:

I am trying to launch my app using an intent like this:

adb shell am start -a android.intent.action.VIEW -d "my_scheme://my_host?queryParam1=QueryParam1&queryParam2=QueryParam2"

(I have registered for the data intent filter with scheme "my_app_scheme" and host "my_host")

But when I do

getIntent().getData()

all I get is the URI

"my_scheme://my_host?queryParam1=QueryParam1"

Only the first ever query param is set in the getIntent().getData(). Do you know why that might be? And how do I fix it?

回答1:

Try it by escaping the ampersand '&' using a '\'

adb shell am start -a android.intent.action.VIEW -d "my_scheme://my_host?queryParam1=QueryParam1\&queryParam2=QueryParam2"