Skip to content

android短信或h5页面唤起app

cheyiliu edited this page Sep 12, 2015 · 1 revision

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已经支持这种无缝跳转了

Clone this wiki locally