指定 ACTION_VIEW
intent 操作,以便能够从 Google 搜索中访问此 intent 过滤器。
添加一个或多个 <data>
标记,每个标记分别代表一种可解析为 Activity 的 URI 格式。<data>
标记必须至少包含 android:scheme
属性。
您可以添加更多属性,以进一步细化 Activity 接受的 URI 类型。例如,您可能拥有多个接受相似 URI 的 Activity,这些 URI 只是路径名称有所不同。在这种情况下,您可以使用 android:path
属性或者其 pathPattern
或 pathPrefix
变体来区分系统应针对不同 URI 路径打开哪个 Activity。
包含 BROWSABLE
类别。如果要从网络浏览器中访问 intent 过滤器,则必须提供。否则,在浏览器中点击链接便无法解析为您的应用。
此外,还要包含 DEFAULT
类别。这样您的应用才可以响应隐式 intent。否则,只有在 intent 指定您的应用组件名称时,Activity 才能启动。
例如 :
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data
android:scheme="example"
android:host="gizmos" />
</intent-filter>
Terminal运行:
adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.android.customview