2015-06-01 66 views
1

我想在Chrome瀏覽器應用程序的某個網頁中點擊<a href="www.myhost.com"/>時打開我的應用程序的LoginActivity。我有這個代碼,但它不工作:在Chrome瀏覽器中點擊href時啓動Android活動

<activity android:label="@string/app_name" android:launchMode="singleTask" 
          android:name=".activities.LoginActivity" android:screenOrientation="portrait" 
          android:windowSoftInputMode="stateVisible"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN"/> 
      <category android:name="android.intent.category.LAUNCHER"/> 
     </intent-filter> 
     <intent-filter> 
      <data android:scheme="http" android:host="myhost.com"/> 
      <category android:name="android.intent.category.DEFAULT"/> 
      <category android:name="android.intent.category.BROWSABLE"/> 
      <action android:name="android.intent.action.VIEW"/> 
     </intent-filter> 
    </activity> 

我在做什麼錯?

謝謝。

回答

2

您需要設置它是這樣的:

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

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

    <data 
     android:host="example.com" 
     android:pathPrefix="/someresource/" 
     android:scheme="http" /> 
    <data 
     android:host="www.example.com" 
     android:pathPrefix="/someresource/" 
     android:scheme="http" /> 
</intent-filter> 

請注意,在你的情況,你將需要使用的android:pathPrefix而不是機器人:路徑。

+0

它就像一個魅力!謝謝 :) –

相關問題