其他分享
首页 > 其他分享> > Android-ADB深层链接触发器无法使用某些参数

Android-ADB深层链接触发器无法使用某些参数

作者:互联网

我的应用程序名称为com.xxx.digital.

以下工作正常:

❯ adb shell am start -W -a android.intent.action.VIEW -d "xxx://?campaign=SG_Smartbanner" com.xxx.digital 
Starting: Intent { act=android.intent.action.VIEW dat=xxx://?campaign=SG_Smartbanner pkg=com.xxx.digital }
Status: ok
Activity: com.xxx.digital/.views.activities.ProductListingActivity
ThisTime: 827
TotalTime: 1669
WaitTime: 1699
Complete

但是,以下内容不会:

❯ adb shell am start -W -a android.intent.action.VIEW -d "xxx://?campaign=SG_Smartbanner&media_source=Mobilesite" com.xxx.digital 
/system/bin/sh: com.xxx.digital: not found

❯ adb shell am start -W -a android.intent.action.VIEW -d "xxx://?campaign=SG_Smartbanner&af_deeplink=true" com.xxx.digital
/system/bin/sh: com.xxx.digital: not found
Starting: Intent { act=android.intent.action.VIEW dat=xxx://?campaign=SG_Smartbanner }
Status: ok
Activity: android/com.android.internal.app.ResolverActivity
ThisTime: 322
TotalTime: 322
WaitTime: 349
Complete

我在这里想念的是什么?

Manifest.xml

<activity
            android:name=".views.activities.DeepLinkActivity"
            android:launchMode="singleInstance"
            android:noHistory="true"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:windowSoftInputMode="stateAlwaysHidden">

            <!-- custom scheme -->
            <intent-filter
                android:autoVerify="true"
                android:label="@string/app_name">
                <action android:name="android.intent.action.VIEW"/>

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

                <data
                    android:scheme="xxx"/>
            </intent-filter>
</activity>

解决方法:

如果使用特殊字符,则必须用引号将adb shell命令包裹起来:

adb shell 'am start -W -a android.intent.action.VIEW -d "xxx://?campaign=SG_Smartbanner&af_deeplink=true" com.xxx.digital'

标签:android-intent,android,deep-linking
来源: https://codeday.me/bug/20191026/1935598.html