2012-07-19 51 views
2

這似乎是一個典型的問題,似乎有很多不同的行爲,但我遇到的問題是,我的計劃將啓動選擇器,並允許我當我點擊電子郵件中的鏈接或設備上的記事時選擇我的應用程序,但是如果我點擊網頁上的鏈接,我似乎無法啓動應用程序,甚至沒有選擇器(我檢查過兩個瀏覽器的「默認值」,而沒有設置)。http scheme intent filter for web from web

<activity 
       android:name=".MyActivity" 
       android:exported="true" 
       android:enabled="true"> 
       <intent-filter> 
        <data android:scheme="http" android:host="www.website.com"/> 
        <data android:scheme="http" android:host="website.com"/> 
        <action android:name="android.intent.action.VIEW" /> 
        <category android:name="android.intent.category.DEFAULT" /> 
        <category android:name="android.intent.category.BROWSABLE" /> 
       </intent-filter> 
    </activity> 

如果用我一個鏈接從電子郵件如下它給我的選擇器,啓動我的應用程序,一切是偉大的,但是,打在網頁瀏覽器相同的鏈接只是沒有選擇器啓動頁面。有什麼問題可能是什麼建議?

http://www.website.com/share.aspx?id=12345678 

測試GS2在Chrome和股票瀏覽器上運行ICS 4.0.3。

+0

我在nexus 7和galaxy nexus上的jellybean上的chrome上有同樣的問題。意圖是從gmail應用程序發送的,但不是來自chrome瀏覽器或銀河聯繫中的傳統瀏覽器。 – Gabriel 2012-08-04 14:57:42

回答

2

這是我如何解決它最終:

<intent-filter> 
      <data 
       android:host="www.website.com" 
       android:pathPattern=".*\\share.aspx" 
       android:scheme="http" /> 
      <data 
       android:host="website.com" 
       android:pathPattern=".*\\share.aspx" 
       android:scheme="http" /> 

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

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

也將添加以下到活動標籤:

android:exported="true" 

的原因有兩個地址,是爲了讓應用程序可以選擇規範域名(帶/不帶www)。

2

添加android:pathPrefix屬性。

<data android:scheme="http" android:host="website.com" android:pathPrefix="/" />