Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android trims the rest of the deep link URI after ampersand

I'm trying to add yet another deep link to my android application, I want my URI to look like this : my_app://photos?id=147619727001201&edit=true. The problem is that the system doesn't recognize this URI, so I just get trimmed version of it (my_app://photos?id=147619727001201). I'm just curious how android system treats deep links, and if there is any way to make this URI work. I wan't to mention that everything works fine for my other URIs, which don't contain ampersand. Here is my intent filter :

               <intent-filter android:label="My Item">
                    <action android:name="android.intent.action.VIEW" />

                    <category android:name="android.intent.category.BROWSABLE" />
                    <category android:name="android.intent.category.DEFAULT" />

                    <data
                        android:path="/photos"
                        android:pathPattern="\?"
                        android:scheme="my_app" />
                </intent-filter>

And here is my activity's on create method :

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Uri target = getIntent().getData();
    }

after the following command :

adb shell am start -a android.intent.action.VIEW -d "my_app://photos?id=170262497002201&edit=true"

I get my_app://photos?id=170262497002201 in target.toString();

like image 264
mdavid Avatar asked May 26 '15 06:05

mdavid


2 Answers

try this command instead:

adb shell am start -a android.intent.action.VIEW -d "my_app://photos?id=170262497002201%26edit=true"

The problem is bug in platform tools version 21 bug issue

like image 121
Karol Żygłowicz Avatar answered Nov 15 '22 04:11

Karol Żygłowicz


You can also try escaping the '&' character by adding a '\' before it

For example:

adb shell am start -a android.intent.action.VIEW -d "fantasticapp://www/?cc=de\&tagset=123" robertoduran.isthegreatest
like image 39
Killesk Avatar answered Nov 15 '22 05:11

Killesk