2016-02-26 55 views
21

我試圖深度鏈接我的應用程序,並在AndroidManifest.xml中實現了以下內容以打開適當的活動。Android與多個查詢參數的深層鏈接

<activity 
    android:name=".ui.activities.MyActivity" 
    android:label="@string/title_activity" 
    android:screenOrientation="portrait"> 
    <!-- ATTENTION: This intent was auto-generated. Follow instructions at 
    https://g.co/AppIndexing/AndroidStudio to publish your Android app deep links. --> 
    <intent-filter> 
     <action android:name="android.intent.action.VIEW" /> 

     <category android:name="android.intent.category.DEFAULT" /> 
     <category android:name="android.intent.category.BROWSABLE" /> 
     <!-- ATTENTION: This data URL was auto-generated. We recommend that you use the HTTP scheme. 
     TODO: Change the host or pathPrefix as necessary. --> 
     <data 
      android:host="myHost" 
      android:scheme="myCustomScheme" /> 
    </intent-filter> 
</activity> 

而且我使用

adb shell am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key=category_parent_id&value=92&title=test" com.myApp.android 

的活動測試亞行活動開幕,但其傳遞給在意向活動的URI只是

myCustomScheme://myHost?key=category_parent_id 

其在'&'

之後跳過所有內容我在此處查看過但沒有用多個查詢參數找到任何東西。

任何幫助,將不勝感激。 :)

回答

48

前請&標誌與亞行測試

副本時,添加\這個

adb shell am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key=category_parent_id\&value=92\&title=test" com.myApp.android

+0

謝謝!那就像魅力一樣工作! –

+0

我的快樂!!!! –

+0

爲我工作。有誰知道你爲什麼需要這樣做? –

5

您可以用簡單的引號包裹shell命令(以避免修改URI內容):

adb shell 'am start -d "myCustomScheme://myHost?key=category_parent_id&value=92&title=test"' 
-1

只需編碼您的網址參數,它將工作。 這可能是谷歌的解析錯誤。

前:

adb shell am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key=category_parent_id&value=92&title=test" com.myApp.android 

後:

adb shell am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key%3Dcategory_parent_id%26value%3D92%26title%3Dtest" com.myApp.android 
1

的OSX/Mac用戶與Android工作室

負載ADB

export PATH="/Users/your_user/Library/Android/sdk/platform-tools":$PATH 

檢查應用程序被公認

adb shell am start -n com.package/.activities_package_name.MainActivity 

測試深層連結

adb shell 'am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key=category_parent_id\&value=92\&title=test" com.myApp.android' 

不要忘記'