2016-07-10 16 views
2

Ich muss Aktivitäten, die ich zu zwei URLs Deep-Link müssen, aber jedes Mal, wenn ich auf eine URL klickt zeigt es die beiden Aktivitäten zur gleichen Zeit, so wie kann ich nur die intent-filter setzen 1 bestimmte URL?Android Deeplinks funktioniert nicht richtig

1. URL http://www.sample.com/newcars/models/33

und seine Aktivität

<activity 
     android:name=".ui.activities.NewCarModelEngineActivity" 
     android:label="@string/newCars" 
     android:screenOrientation="sensorPortrait"> 
     <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="sample.com" 
       android:pathPrefix="/newcars/engines/" 
       android:scheme="http"/> 
      <data 
       android:host="www.sample.com" 
       android:pathPrefix="/newcars/engines/" 
       android:scheme="http"/> 

      <data 
       android:host="newengine" 
       android:pathPattern="/..*/..*/..*" 
       android:scheme="sample"></data> 

     </intent-filter> 
    </activity> 

2. URL http://www.sample.com/usedcars/engines/9876543 und seine Aktivität

<activity 
     android:name=".ui.activities.UsedCarEngineDetailsActivity" 
     android:label="@string/usedCars" 
     android:screenOrientation="sensorPortrait"> 
     <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="sample.com" 
       android:pathPrefix="/usedcars/engines/" 
       android:scheme="http"/> 
      <data 
       android:host="www.sample.com" 
       android:pathPrefix="/usedcars/engines/" 
       android:scheme="http"/> 
      <data 
       android:host="usedengine" 
       android:pathPattern="/..*/..*/..*" 
       android:scheme="sample"></data> 
     </intent-filter> 
    </activity> 

Antwort

0

Versuchen Sie, Ihre scheme="sample" Daten in einem separaten Intent-Filter zu setzen. Es scheint wie ein Fehler, aber manchmal ignoriert Android einfach das Pfadpräfix, wenn ein anderes vorhanden und leer ist oder mit Platzhaltern.

Sie können auch host="*sample.com" verwenden, um sowohl sample.com als auch www.sample.com zu entsprechen.

Ex für Ihre erste Aktivität:

<activity 
    android:name=".ui.activities.NewCarModelEngineActivity" 
    android:label="@string/newCars" 
    android:screenOrientation="sensorPortrait"> 

    <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:scheme="http" 
      android:host="*sample.com" 
      android:pathPrefix="/newcars/engines/" /> 

    </intent-filter> 

    <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:scheme="sample" 
      android:host="newengine" 
      android:pathPattern="/..*/..*/..*" /> 

    </intent-filter> 

</activity> 
+0

Ich habe gerade versucht, dass und es hat nicht funktioniert, zeigt es nach wie vor beiden Aktivitäten. –