2015-10-19 103 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