2016-01-18 42 views
2

我知道這個問題可能會出現重複其他一些類似的問題。我已經審查了所有這些問題,但仍無法解決此問題。Android的意圖過濾器https計劃不起作用

我想在點擊網頁上的鏈接時啓動我的android應用程序。它的工作原理是,當我使用自定義方案所需:

<!-- In the deployed webpage: --> 
<a href="test://test.com">Launch application </a> 

<!-- The Intent filter: --> 
<intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="test" android:host="test.com" /> 
</intent-filter> 

更改方案時,但爲「https」:

<!-- In the deployed webpage: --> 
<a href="https://test.com">Launch application </a> 

<!-- The Intent filter: --> 
<intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:scheme="https" android:host="test.com"/> 
</intent-filter> 

瀏覽器試圖打開(不存在)頁面,並忽略意圖過濾器。 它不用於HTTP,HTTPS,FTP等工作

我運行的應用程序在Android 6.0,編譯:最低11,目標23

好像一些機制還不讓我使用「保留」方案啓動應用程序,但我在帖子中沒有看到與此相關的任何內容。

你有什麼線索可以做什麼?

回答

1

與Android棉花糖開始您可以使用一個新的android:autoVerify標誌來請求Android驗證某個域是否屬於您,並且您希望鏈接在您的應用中打開,而不是在瀏覽器中打開。

「的Android 6.0(API級別23)和更高允許應用程序指定 本身作爲給定鏈路的類型的默認處理程序」

參見:https://developer.android.com/training/app-links/index.html#intent-handler

+0

好吧,我認爲這是問題的根源。我會盡快接受答案。你知道應用鏈接驗證是否適用於自簽名SSL證書? – user1275011

+0

也應該爲自簽名ssl工作 – marmor

0

嘗試連接兩個data標籤像這樣,並刪除第android.intent.category.DEFAULT類作爲其不需要在第一意圖過濾器在所有的,而且是必要的二號使"the activity should be an option for the default action to perform on a piece of data"

<activity android:name=".MainActivity"> 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
    <intent-filter> 
     <action android:name="android.intent.action.VIEW" /> 
     <category android:name="android.intent.category.BROWSABLE" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <data android:scheme="https" android:host="test.com" /> 
    </intent-filter> 
</activity> 
+0

可以編輯您的問題,並從您的AndroidManifest.xml文件中爲有問題的活動(intent-filter標記的父標記的完整內容)提供完整的xml。 – petey

+0

我按照要求編輯了問題。但請記住,這實際上適用於任何自定義模式。只有使用「http」或「https」時纔會失敗。 – user1275011