我正在尝试进行深层链接,以便当有人从移动浏览器打开链接时,它会打开应用程序,如果已安装或打开播放商店链接以下载应用程序.
这是我的URI:
intent://scan/#Intent;scheme=com.example.android;package=com.example.android;end
Run Code Online (Sandbox Code Playgroud)
当我在Android上的Mozilla Firefox应用程序中键入此内容时,如果安装了它,则会打开我的应用程序,如果未安装,则会打开播放商店链接.但是,当我在Chrome中键入相同的内容时,它只是进行谷歌搜索,而不是打开应用程序或播放商店.我的解决方案有什么问题,我该如何使其运作?
我在 Android Studio 中启动了一个新项目并将其添加到我的androidmanifest.xml:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="www.example.com"
android:pathPrefix="/gizmos"
android:scheme="http"/>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
然后我转到 Google Chrome 并输入:http://www.example.com/gizmos。该应用程序打不开。然后尝试命令行:
mac-van-jim:DeeplinkTest jimclermonts$ adb shell am start -n eu.theappfactory.deeplinktest/MainActivity
Starting: Intent { cmp=eu.theappfactory.deeplinktest/MainActivity }
Error type 3
Error: Activity class {eu.theappfactory.deeplinktest/MainActivity} does not exist.
Run Code Online (Sandbox Code Playgroud)
和这个:
mac-van-jim:DeeplinkTest jimclermonts$ adb shell am start -W -a android.intent.action.VIEW -d "http://www.example.com" eu.theappfactory
Starting: Intent { act=android.intent.action.VIEW dat=http://www.example.com/... pkg=eu.theappfactory }
Error: Activity …Run Code Online (Sandbox Code Playgroud)