【问题标题】:Is there any way to know whether an Android App Link will open an app or not?有什么方法可以知道 Android App Link 是否会打开应用程序?
【发布时间】:2020-01-18 18:34:56
【问题描述】:

是否有一种编程方式可以知道 HTTPS URL 是否会使用 Android App Links 打开 Android 应用程序?

对于通用链接(iOS 等效的 App 链接),可以在链接出时使用 static let universalLinksOnly: UIApplication.OpenExternalURLOptionsKey(记录为 here)以确保 URL 是否会打开应用程序。是否有与此等效的 Android 应用程序链接?

【问题讨论】:

  • 您可以使用 Android Studio 的 App Links Assistant 测试应用链接。设置链接后,您可以选择对其进行测试。

标签: android ios hyperlink linker universal


【解决方案1】:
<activity
    android:name=".ui.activity.TestActivity"
    android:label="@string/app_name"
    android:launchMode="singleTask"
    android:screenOrientation="portrait">
    <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:scheme="testapp"
            android:host="host1"
            android:path="/path1"
            android:port="8080" />
    </intent-filter>
</activity>

然后:

<a href="testapp://host1:8080/path1?query1=1&query2=true">Open from App</a>

其中,scheme和host为必填项,其他要求视你的实际需要而定。

【讨论】:

  • 这是一个完全不同(更简单)的问题的答案。
猜你喜欢
  • 2011-10-10
  • 2023-04-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-01-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多