2015-10-19 65 views
0

我想建立一个应用程序,如果我点击链接我的应用程序(如果安装)将打开。但它不工作,不知道为什么。它总是重定向到谷歌。 COM点击网页链接应用程序将打开

我的清单文件

<activity android:name=".DeeplinkingActivity" 
      android:label="@string/app_name" 
      android:exported="true" 
      android:launchMode="singleTop" 
      android:theme="@android:style/Theme.Holo.NoActionBar"> 
      <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" /> 
       <!-- Accepts URIs that begin with "http://example.com/soham" --> 
       <data android:scheme="http" 
        android:host="example.com" 
        android:pathPrefix="/soham" /> 
       <data android:scheme="http" 
        android:host="www.example.com" 
        android:pathPrefix="/soham" /> 
      </intent-filter> 
     </activity> 

我的test.html

<a href="intent://scan/#Intent;scheme=http;package=soham.com.deeplinking;S.browser_fallback_url=http%3A%2F%2Fgoogle.com;end"></a> 

我认为这个问题是在HTML file.Any帮助?

回答

1

您的链接是不正确,您使用的是Android Intents with Chrome example的主机你的发射活动标签内。您需要使用在AndroidManifest.xml中配置的hostpathPrefix

hostexample.com和你pathPrefix/soham,链接将变成:

<a href="intent://example.com/soham#Intent;scheme=http;package=soham.com.deeplinking;S.browser_fallback_url=http%3A%2F%2Fgoogle.com;end">Deeplink</a> 
+0

Thanks.It正在工作。可以告诉我如何通过链接发送参数。假设我必须发送id = 1,2。 – Soham

+0

不客气。 [这个答案](http://stackoverflow.com/a/21304773/2837959)详细解释了如何将参数作为额外事件传递给应用程序。 –

+0

太棒了。再次感谢 – Soham

0

试试这个:这是工作为我的应用程序:

注:下面写代码

<intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
     <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" /> 

      <!-- Accepts URIs that begin with "example://WRITE YOUR HOST NAME” --> 
      <data 
       android:host="index.html" 
       android:scheme="WRITE YOUR HOST NAME" /> 
     </intent-filter> 
     <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" /> 

      <!-- Accepts URIs that begin with "http://example.com/WRITE YOUR HOST NAME” --> 
      <data 
       android:host="WRITE YOUR HOST NAME.com" 
       android:pathPrefix="/index.html" 
       android:scheme="http" /> 
     </intent-filter> 
     <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:scheme="WRITE YOUR HOST NAME" /> 
     </intent-filter> 
+0

这是示例应用程序,而不是在Play商店中,没有任何website.So应该是什么安卓方案和android:host – Soham

相关问题