我正在关注 App Indexing API doc .
我的应用程序 URI 是 android-app://com.mypackagename.app/intro/intro/
,所以我将其添加到 <activity>
下的 list 文件中
<activity
android:name=".MainActivity"
android:label="@string/config_app_name"
android:screenOrientation="portrait"
android:enabled="true"
android:exported="true"
>
<intent-filter android:label="test">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="android-app"
android:host="com.mypackagename.app" />
</intent-filter>
</activity>
但是当去测试我的深层链接时,如 Test your deep link 中所述在我的手机上,链接 android-app://com.mypackagename.app/intro/intro/
打不开, toast 说“没有安装可以处理的应用”
我错过了什么?谢谢
更新:在 Mattia 指出的文档中,绝对可以选择放置任何方案,例如“示例”,但它对我不起作用。我在 Lollipop 上,如果它有所作为的话。
<intent-filter android:label="@string/filter_title_viewgizmos">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "example://gizmos" -->
<data android:scheme="example"
android:host="gizmos" />
</intent-filter>
更新 2:包之后的任何内容都是方案,在我的例子中,android-app://com.mypackagename.app/intro/intro/
, 它是 intro
.下面标记的答案
最佳答案
您应该使用您的域,而不是 android-app
和您在 documentation 中看到的包.
试试这个例子:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test">
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateVisible">
<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="yourdomain"
android:scheme="example" />
</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.yourdomain.com"
android:scheme="http" />
</intent-filter>
</activity>
</application>
</manifest>
比试here使用这些值(将 com.example.test
更改为您应用程序的包名称):
android-app://com.example.test/http/www.yourdomain.com/page
android-app://com.example.test/example/yourdomain/page
当您扫描条形码并按下链接时,您的应用程序将自动打开。
关于Android 深度链接,无法使用方案 'android-app' 过滤 Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30037523/