短信或h5頁面喚起android app

android短信或h5頁面喚起app

需求

  • 點擊短信或h5內鏈接跳轉:若androud手機安裝了目標app則跳到該app某頁面;若沒安裝則跳到app的html下載頁

思路

  • 通過scheme機制實現頁面喚起。

實現

  • android app內頁面scheme配置
        <activity
            android:name="com.example.test4link2app_target.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <data
                    android:host="my.host.com"
                    android:path="/get/info"
                    android:scheme="myscheme" />

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

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

                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
        </activity>
  • h5頁面配置
<a href="myscheme://my.host.com/get/info?id=10000" >點擊打開目標app</a>

Demo工程

其他

  • 這裏自定義的scheme可以考慮採用http,但這樣會導致在點擊鏈接後系統彈出一個選擇框,若本地安裝了app則app會出現在列表,若沒安裝則默認器瀏覽器
  • android6已經支持這種無縫跳轉了
發佈了113 篇原創文章 · 獲贊 6 · 訪問量 19萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章