浏览器启动APP

作者: 沅兮 | 来源:发表于2017-10-11 11:29 被阅读0次
做一个测试的html页面
  • html页面内容格式如下:
<a href="[scheme]://[host]/[path]?[query]">start APP</a>
> scheme:判别启动的app。
> host:标记
> path:传值时必须的key(可以没有)
> query:获取值的key和value(可以没有)
  • 测试的html如下:
<a href="app://com.app/openwith?name=lbj&age=18">start APP</a>
Android端改写
  • 在AndroidManifest.xml的启动的activity下追加以下内容
<intent-filter>  
    <action android:name="android.intent.action.MAIN"/>  
    <category android:name="android.intent.category.LAUNCHER" />  
</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="app" android:host="com.app" android:pathPrefix="/openwith"/>  
</intent-filter>
> 上面有两个<intent-filter>,一个用于app自己启动,一个用于浏览器打开,必须分开写
> <data>标签中的scheme和host必须对应html中设置的数据,且scheme内容必须为小写
在app中获取html传过来的值
Intent intent= getIntent();  
String action = intent.getAction();  
  
if(Intent.ACTION_VIEW.equals(action)){  
    Uri uri = intent.getData();  
    if(uri != null){  
        String name = uri.getQueryParameter("name");  
        String age= uri.getQueryParameter("age");  
    }  
}
浏览器启动app
  • 将写好的html存放在手机中
  • 用浏览器打开此html
  • 点击"start APP",打开目标app

相关文章

  • 浏览器启动app简单记录

    简单记录下浏览器启动app 浏览器格式如下: 启动应用程序 scheme:判别启动的App。 ※详细后述host:...

  • Appium+python自动化17-启动iOS模拟器APP源码

    前言 上一篇已经可以启动iOS模拟器上的safari浏览器了,启动app比启动浏览器要复杂一点,本篇以github...

  • 浏览器启动APP

    做一个测试的html页面 html页面内容格式如下: 测试的html如下: Android端改写 在Android...

  • ReactNative开发之url跳转app

    StackNavigator中添加path,在手机浏览器中输入:app名称://path 来启动该App,并进入p...

  • iOS-关于URL schema

    URL schema用于其他 APP 或者浏览器启动此 APP 的标识 添加 在 URL Types 上添加一个 ...

  • iOS app启动优化方案

    一、APP的启动 二、App启动阶段 APP的启动 - dyld APP的启动 - runtime APP的启动 ...

  • 外链调起APP页面

    简述:Android 通过URL scheme 实现点击浏览器中的URL链接,启动特定的App,并调转页面传递参数...

  • iOS面试-启动优化

    APP启动 APP的启动方式 冷启动(Cold Launch):从零开始启动APP 热启动(Warm Launch...

  • iOS启动性能优化篇

    APP启动 APP的启动方式 冷启动(Cold Launch):从零开始启动APP 热启动(Warm Launch...

  • iOS启动优化

    APP 启动 APP的启动可以分为2种: 冷启动(Cold Launch):从零开始启动APP 热启动(Warm ...

网友评论

    本文标题:浏览器启动APP

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