繁体   English   中英

深度链接无法在http方案中打开应用

[英]Deep link not open app in http scheme

我已经在清单文件中的应用程序中实现了深层链接,我已经定义了这样的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方案-网址打开的应用程序,运行完美

http scheme-url打开浏览器不是实际的App? 我想念什么吗?

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

和在Android 7.1.1中通过应用安装

https方案-url打开应用程序并能完美工作http方案-url打开应用程序并能完美工作(编辑)

首先,使用以下命令检查链接是否可以通过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>

尝试通过浏览器<a href="http://appsdata2.cloudapp.net"></a>测试链接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM