2016-10-11 67 views
1

我有申请意向过滤器活动打开深层链接,这是我的意图过滤器:Android的深层链接没有Android:方案

<intent-filter android:autoVerify="true"> 
       <category android:name="android.intent.category.DEFAULT" /> 

       <action android:name="android.intent.action.VIEW" /> 

       <category android:name="android.intent.category.BROWSABLE" /> 

       <data 
        android:host="www.example.com" 
        android:pathPattern="/..*" 
        android:scheme="https" /> 
</intent-filter> 

我的问题是,当用户打开一个链接,即“www.example。 com/somepage“,例如环聊,WhatsApp,Android应用选择器不会在其列表中显示可能的应用,它只显示选项中的所有浏览器应用。但是当用户在消息中输入“https://www.example.com/somepage”后,Android会在App选择器中显示我的应用程序以打开链接。 它也不起作用当我尝试从我的意图过滤器中删除android:scheme="https"

有没有人有同样的问题,并有解决方案?

任何帮助真的很感激。

回答

0

这是预期的行为。

什么下面的代码片段确实是注册您的应用程序作为URL方案https://

<data 
    android:host="www.example.com" 
    android:pathPattern="/..*" 
    android:scheme="https" /> 

这意味着你的应用程序将提供作为任何关联https://开始,包含www.example.com选项的处理程序。字符串www.example.com/somepage不符合条件,因为它缺少https://部分。

您可以尝试为http://链接添加过滤器。我不确定Android是否会自动推断为没有指定方案的Web链接方案,因此可能可以解决此问题。

<intent-filter android:autoVerify="true"> 
    <category android:name="android.intent.category.DEFAULT" /> 

    <action android:name="android.intent.action.VIEW" /> 

    <category android:name="android.intent.category.BROWSABLE" /> 

    <data 
     android:host="www.example.com" 
     android:pathPattern="/..*" 
     android:scheme="https" /> 

    <data 
     android:host="www.example.com" 
     android:pathPattern="/..*" 
     android:scheme="http" /> 
</intent-filter>