2017-08-18 58 views
0

我在清单文件中使用了以下意图过滤器的深度链接概念。如何从外部应用程序如WhatsApp或Facebook点击链接时启动我的Android应用程序?

<activity 
     android:name=".MyActivity" 
     android:screenOrientation="portrait" 
     android:windowSoftInputMode="stateAlwaysHidden" > 
     <intent-filter android:label="@string/app_name"> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <data 
       android:host="test.myapp.com" 
       android:scheme="http" 
       /> 
     </intent-filter> 
    </activity> 

这有助于我在什么应用上点击链接时,显示我的应用程序, 但它显示了在像铬列表中的其他应用程序,互联网等 我怎样才能让只能直接链接点击后访问我的应用程序在其他应用程序,如最新的应用程序?

回答

1

我唯一的想法是添加一个意图过滤器,该过滤器在设备打开特殊URL(例如www.your-project.com)时启动您的应用程序。看看这个 documentation它解释了所有社交网站链接到您的应用程序。

如果用户安装了您的应用程序,点击该链接将打开您的应用程序。否则,链接将由您的默认浏览器打开。

0

您只想从Android 6.0中实现,在Android 6.0中,您可以绕过Intent选择器对话框,然后直接点击链接启动应用程序。

为此,请检查此App link文档。他们已经很好的解释如何做到这一点

,你也有可能通过添加参数android:autoVerify="true"

<activity ...> 

<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:scheme="http" android:host="www.example.com" /> 
    <data android:scheme="https" /> 
</intent-filter> 

作出如下图所示的意图过滤稍作修改
相关问题