2017-06-13 1 views
2

Ich habe, sagen wir, Domain example.com. Es kann mit https und http zusammenarbeiten. Und ich habe Android-Client für diesen Dienst. Ich möchte, dass der Client mehrere Verbindungstypen öffnen kann. Hier sind sie:Wie werden App-Links bei verschiedenen Aktivitäten gehandhabt?

Diese vier sollten auf der ListActivity geöffnet werden. Aber es gibt auch andere Verbindungen wie:

https://testask.com/i/__some_guid__ 
https://testask.com/item/__some_guid__ 
and relevant link without https 

Sie sollten auf eine andere Tätigkeit geöffnet werden, sagen wir, DetailsActivity. Zur Zeit habe ich folgende Absicht Filter für DetailsActivity:

Und sieht aus wie es richtig funktioniert. Aber ich verstehe nicht, wie man MainActivity Intent-Filter hinzufügen kann, um auf die Root-Host-URL zu zeigen und den DetailsActivity Intent-Filter nicht zu überlappen.

Antwort

0

Welp, nach einigen Versuchen fand ich, dass folgende Intent-Filter wie erwartet funktioniert:

 <intent-filter 
      android:autoVerify="true" 
      tools:targetApi="m"> 
      <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" /> 
      <data android:scheme="https" /> 
      <data android:host="@string/root_host_endpoint" /> 
      <data 
       android:host="@string/root_host_endpoint" 
       android:path="/" /> 
      <data 
       android:host="@string/root_host_endpoint" 
       android:path="/app" /> 
     </intent-filter> 
0

Sie könnten mehrere Aktivitäten mit verschiedenen Intent-Filtern haben. Sie können Ihre Intent-Filter mithilfe von Aktion/Kategorie/Daten unterscheiden. In Ihrem Fall müssen Sie Ihre Datenkonfiguration so anpassen, dass sie verschiedene Absichten berücksichtigt. So MainActivity/ListActivity wird eine andere Datenkonfiguration haben im Gegensatz zu DetailsActivity

+0

Danke, ich verstehe es, ich habe gerade nicht bekommen, wie man es in xml schreibt. – Bringoff

0
<activity android:name=".ListActivity"> 
<intent-filter 
android:autoVerify="true" 
tools:targetApi="m"> 
<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" /> 
<data android:scheme="https" /> 
<data 
    android:host="example.com" 
    android:pathPattern="/*/.*" /> 
</intent-filter> 
</activity> 

<activity android:name=".DetailsActivity"> 
<intent-filter 
android:autoVerify="true" 
tools:targetApi="m"> 
<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" /> 
<data android:scheme="https" /> 
<data 
    android:host="@string/root_host_endpoint" 
    android:pathPattern="/i/.*" /> 
<data 
    android:host="@string/root_host_endpoint" 
    android:pathPattern="/item/.*" /> 
</intent-filter> 
</activity> 
+0

Leider hat es nicht gelenk http://example.com https://example.com http://example.com/app https://example.com/app – Bringoff

+0

hinzufügen

Verwandte Themen