android deep link(深度連結)與自訂協議!,androiddeep

來源:互聯網
上載者:User

android deep link(深度連結)與自訂協議!,androiddeep

此自訂僅供參考!

首先開啟androidManifest.xml

在MainActivity中添加如下內容:

<activity android:name=".MainActivity">    ......  <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="com.example.androidtest"       />  </intent-filter></activity>
其中data標籤裡面android:scheme用於指定協議,類似於http這樣的東西,這裡我們指定成了com.example.androidtest,
這是一個自訂的協議,指定成這樣是為了避免和其它的應用程式衝突.
我們還可以通過android:host來指定網域名稱,android:port來指定連接埠,android:path來指定路徑,
這些屬性都可以對deep links進行更多的限制,要滿足特定條件才能開啟指定App.
順便說下https://www.baidu.com/s?cl=3&wd=deeplink 拆分的意思對應下面的
scheme://host:port/pathorpathPrefixorpathPattern
https表示加密的協議 對應android data標籤裡面的scheme
www.baidu.com 表示網域名稱 對應data標籤裡面的host
s 表示連接埠 對應data標籤裡面的port
cl=3&wd=deeplink 表示path路徑 對應data標籤裡面的path
這些屬性是可選的,但也是相互依賴的。如果沒有給Intent過濾器指定scheme屬性,那麼所有其他的URI屬性都會被忽略。如果沒有給過濾器指定host屬性,那麼port屬性和所有的路徑屬性都會被忽略。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.