Android - 更新 SDK 版本 23 后添加至少一个带有 ACTION-VIEW 意图过滤器的 Activity

2024-03-20

我收到以下工具提示AndroidManifest.xml:

应用程序无法被 Google 搜索索引;考虑添加至少一个 具有 ACTION-VIEW 意图填充器的活动。请参阅问题说明 更多细节。

添加深层链接以使您的应用程序进入 Google 索引, 从 Google 搜索获取应用的安装量和流量。

谁能解释为什么会这样?


来自官方文档:

要使 Google 能够抓取您的应用内容并允许用户从搜索结果输入您的应用,您必须在应用清单中为相关活动添加意图过滤器。这些意图过滤器允许深层链接到您的任何活动中的内容。例如,用户可能单击深层链接来查看购物应用程序中描述用户正在搜索的产品的页面。

使用此链接为应用程序内容启用深层链接 http://developer.android.com/training/app-indexing/deep-linking.html你会看到如何使用它。

并使用这个测试您的应用程序索引实施 https://developers.google.com/app-indexing/android/test如何测试它。

以下 XML 片段显示了如何指定意图过滤器 在您的深层链接清单中。

<activity
    android:name="com.example.android.GizmosActivity"
    android:label="@string/title_gizmos" >
    <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 "http://www.example.com/gizmos” -->
        <data android:scheme="http"
              android:host="www.example.com"
              android:pathPrefix="/gizmos" />
        <!-- note that the leading "/" is required for pathPrefix-->
        <!-- Accepts URIs that begin with "example://gizmos” -->
        <data android:scheme="example"
              android:host="gizmos" />

    </intent-filter>
</activity>

通过 Android 调试桥进行测试

$ adb shell am start
        -W -a android.intent.action.VIEW
        -d <URI> <PACKAGE>

$ adb shell am start
        -W -a android.intent.action.VIEW
        -d "example://gizmos" com.example.android
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android - 更新 SDK 版本 23 后添加至少一个带有 ACTION-VIEW 意图过滤器的 Activity 的相关文章

随机推荐