Android 修剪 link 符号后的其余深度 URI

Android trims the rest of the deep link URI after ampersand

我正在尝试向我的 android 应用程序添加另一个深度 link,我希望我的 URI 看起来像这样:my_app://照片?id=147619727001201&edit=true。问题是系统无法识别这个 URI,所以我只得到它的修剪版本 (my_app://photos?id=147619727001201)。我只是好奇 android 系统如何处理深 links,以及是否有任何方法可以使这个 URI 工作。我不想提及我的其他 URI 一切正常,它们不包含 & 符号。这是我的意图过滤器:

               <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>

这是我的 activity 创建方法:

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

在执行以下命令后:

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

我在 target.toString();[ 中得到 my_app://photos?id=170262497002201 =15=]

试试这个命令:

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

问题是平台工具版本 21 中的错误 bug issue

您也可以尝试通过在“&”字符前添加“\”来转义它

例如:

adb shell am start -a android.intent.action.VIEW -d "fantasticapp://www/?cc=de\&tagset=123" robertoduran.isthegreatest