我尝试深层链接我的应用,并在我的AndroidManifest.xml中实现了以下功能,以打开正确的活动。
<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中的活动adb shell am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key=category_parent_id&value=92&title=test" com.myApp.android
活动正在打开,但传递给intent中活动的URI仅为
myCustomScheme://myHost?key=category_parent_id
在&#39;&amp;&#39;
之后跳过所有内容我确实在SO上查找但没有找到任何包含多个查询参数的内容。
答案 0 :(得分:84)
在使用adb进行测试时,只需在\
符号前添加&
。
复制此内容:
adb shell am start -W -a android.intent.action.VIEW -d "myCustomScheme://myHost?key=category_parent_id\&value=92\&title=test" com.myApp.android
答案 1 :(得分:14)
您可以使用简单的引号包装shell命令(以避免修改uri内容):
firstShader
答案 2 :(得分:1)
对于使用android studio的osx / mac用户
加载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'
别忘了&#39; &#39;
答案 3 :(得分:-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