美文网首页
AppDeepLink (唤起APP)

AppDeepLink (唤起APP)

作者: yoosir | 来源:发表于2017-01-23 11:04 被阅读0次

情景:在浏览器中唤起我们自己的应用

配置:

1. 首先,在HTML的页面中添加如下格式链接:

第一种方式:<a href="[scheme]://[host]/[path]?[query]">启动应用程序</a>
举例:

<a href="http://example.com/status?name=yoosir&age=20">启动应用程序</a>

第二种方式:<a href="[scheme]://[host]/[path]/parameters">启动应用程序</a>
举例:

<a href="http://example.com/status/1234">

2.在AndroidManifest.xml中做如下配置:

        <activity android:name=".activity.SplashActivity">
             ....//其他 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="http"             //对应url中的scheme    可以定义成自己特定的,比如 my.special.scheme
                    android:host="example.com"   //对应url 中的 host
                    android:pathPrefix="/status"    //对应url中的path   **注意**: /  需要这里添加
                     />
            </intent-filter>
        </activity>

3.在代码中对点击事件做处理

//一般在 activity的 onCreate中做处理

/** 对应URL 的第一种配置方法 **/
String action = getIntent().getAction();
if(Intent.ACTION_VIEW.equals(action)){
    //可以通过Action 来判断是不是浏览器启动
    Uri uri = i_getvalue.getData();
}
if(uri != null){
    String scheme = data.getScheme(); // "http"
    String host = data.getHost(); // "example.com"
    String name = uri.getQueryParameter("name"); // "yoosir"
    String age= uri.getQueryParameter("age");       // "20"
}

/** 对应URL 的第二种配置方法 **/
Uri data = getIntent().getData();
String scheme = data.getScheme(); // "http"
String host = data.getHost(); // "example.com"
List<String> params = data.getPathSegments();
String first = params.get(0); // "status"
String second = params.get(1); // "1234"

4.特殊操作

//经测试,在小米手机的默认浏览器和UC上都可以正常运行
启动应用Dialog <a href="http://example.com/openwith"> click me  </a>

//经测试,在小米手机的默认浏览器可以正常运行。UC上没反应
package= 应用包名
启动应用没有Dialog:<a href="intent://example.com/openwith#Intent;scheme=http;package=com.xxx.xxx;end;"> click me  </a>

总结下:

  1. 第三方浏览器,对 "#Intent;scheme=http;package=com.xxx.xxx;end;"默认不识别,所以不推荐使用这种方式。
  2. 在QQ中通过以上方法可以唤醒应用。
  3. 在微博和微信中不可行。

最后一个技巧:

我们可以写一个 带有链接的 html 文件在手机上用浏览器打开测试。但是,QQ上怎么测试呢?
大家可以直接在简书上写一个链接

//链接就放你们自己定义的,就可以通过打开文章链接,找到并 点击 启动应用,就可以在QQ上唤醒你的应用了。
 [启动应用]("http://example.com/openwith")

相关文章

  • AppDeepLink (唤起APP)

    情景:在浏览器中唤起我们自己的应用 配置: 1. 首先,在HTML的页面中添加如下格式链接: 第一种方式: 启动应...

  • iOS中APP间的唤起

    概念 所谓APP间的唤起就是这个软件通过某个事件唤起了另外一个APP。 实现方式 APP间唤起通过scheme来实...

  • React Native Linking与 Android原生页

    Linking 唤起APP.检查该app能否被唤起,也就是检查该app是否已安装成功;Linking提供了canO...

  • 通用跳转

    https://damai.cn/test.html 点击跳转(可以直接唤起app) 点击跳转(不可以直接唤起app)

  • 获取app的scheme url

    1、打开chrome开发者工具2、选择手机模式3、打开相关url(需要可以唤起app)4、点击唤起app

  • Swift_APP唤起APP

    做微信和支付宝支付的时候,好奇是如何在app内能指定打开哪个app的,以及如何做信息传递的? 一. 什么叫 URL...

  • ios-App唤起

    1,检查有没有App https://www.jianshu.com/p/f53ed629cb0a 2,唤起端和被...

  • 关于JS唤起APP

    产品需求:点击按钮 当用户安装了APP则开启APP 否则跳到下载页面 坑:JS是无法判断系统中是否安装了某个APP...

  • 解决6.5.16及以上版本微信内部M页不能唤起APP

    背景 最近微信唤起app的数据急速下降,产品同学告诉我们大事来了,微信不能唤起Android的App了!! 微信语...

  • Android DEPPLINK及APPLink原理简析

    APP开发中经常会有这种需求:在浏览器或者短信中唤起APP,如果安装了就唤起,否则引导下载。对于Android而言...

网友评论

      本文标题:AppDeepLink (唤起APP)

      本文链接:https://www.haomeiwen.com/subject/gmjobttx.html