根据官方文档:
为了让Google能够爬取你的应用程序内容,并允许用户通过搜索结果进入你的应用程序,你必须在应用程序清单中为相关活动添加意图过滤器。这些意图过滤器允许深层链接到任何活动中的内容。例如,用户可能会点击一个深度链接,以查看描述他正在搜索的产品提供的购物应用程序中的页面。
你可以使用此链接Enabling Deep Links for App Content了解如何使用它。
并使用此链接Test Your App Indexing Implementation来测试它。
以下 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
ACTION-VIEW
的intent-filter,但解决方案涉及到action.VIEW
。同样地,在Android Studio中跟随链接会带你进入一个没有出现ACTION-VIEW
的网页。至少他们在显眼的警告中应该给出准确的信息和帮助页面。 - John Perrymanifest
标签中添加xmlns:tools="http://schemas.android.com/tools"
,然后在application
标签中添加tools:ignore...
。 - John Perry<activity>
内部的<intent-filter>
中添加以下代码来删除警告。<action android:name="android.intent.action.VIEW" />
tools:ignore="GoogleAppIndexingWarning"
移除警告,我在主活动中将其作为<action android:name="android.intent.action.MAIN" />
的同级添加。 - Daniel Ftools:ignore="GoogleAppIndexingWarning"
,因为这样就不会添加一个空ACTION_VIEW。它可能不会引起任何问题,但你始终希望保持安全。 - Carson J.<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.app"
tools:ignore="GoogleAppIndexingWarning">
您可以通过在 <manifest>
标签中添加 xmlns:tools="http://schemas.android.com/tools"
和 tools:ignore="GoogleAppIndexingWarning"
来移除此警告。
我在应用程序清单中声明的一个活动中添加了此意图过滤器,这为我解决了问题。
<activity
android:name=".MyActivity"
android:screenOrientation="portrait"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
这个解决方法仅适用于您希望忽略此警告的情况。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="GoogleAppIndexingWarning"
package="com.example.saloononlinesolution">