【问题标题】:Deep link not open app in http scheme深层链接未在 http 方案中打开应用程序
【发布时间】:2018-02-12 14:52:06
【问题描述】:

我已经在清单文件中的应用程序中实现了深层链接,我已经像这样定义了intent-filter

<activity
        android:name=".activity.ProfilePreviewActivity"
        android:theme="@style/AppTheme.ActionBar.Transparent">
        <intent-filter android:autoVerify="true" android:label="@string/app_name"
                       tools:targetApi="m">
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:host="appsdata2.cloudapp.net"
                  android:scheme="https"
            />
        </intent-filter>
        <intent-filter android:autoVerify="true" >
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <data
                android:host="appsdata2.cloudapp.net"
                android:scheme="http"
            />
        </intent-filter>

 </activity>

现在的问题是:

我已经为两者定义了方案,还添加了android:autoVerify="true"

在 Android 6.0.1 中使用应用安装

https 方案 - url 打开应用程序并完美运行

http 方案 - url 打开浏览器不是实际的应用程序?我错过了什么吗?

我已经关注https://stackoverflow.com/a/39486914/1293313 但没有运气

在 Android 7.1.1 中安装应用

https 方案 - url 打开应用程序并完美运行 http 方案 - url 打开应用程序并完美运行(已编辑)

【问题讨论】:

    标签: android deep-linking android-7.0-nougat android-7.1-nougat


    【解决方案1】:

    首先检查 adb 是否可以访问链接:

    adb shell am start -n com.example.simon.test/.activity.ProfilePreviewActivity
    

    请尝试以下代码,因为 chrome 在打开链接时存在一些问题。

    <activity
             android:name=".activity.ProfilePreviewActivity"
             android:theme="@style/AppTheme.ActionBar.Transparent">
    
        <!-- For chrome links -->
        <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="appsdata2.cloudapp.net"
                   android:scheme="http"
                   android:pathPrefix="/"/>
        </intent-filter>
    
        <!-- For adb -->
        <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="appsdata2.cloudapp.net"
                android:scheme="http"/>
        </intent-filter>
    
     </activity>
    

    尝试从浏览器&lt;a href="http://appsdata2.cloudapp.net"&gt;&lt;/a&gt;测试链接

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-10
      • 2022-01-08
      • 2021-01-26
      • 2017-11-16
      • 1970-01-01
      • 2016-06-26
      • 2020-07-23
      • 1970-01-01
      相关资源
      最近更新 更多