功能需求描述:在手机端web页面点击一个按钮(或者a标签),实现启自己APP的目的。
H5页面端:
<div>
<a href="http://myapp.com">启动APP</a>
</div>
Android端:
//指定文档类型及编码格式,由系统已安装的解释器解析。
<?xml version="1.0" encoding="utf-8"?>
//根标签 指定系统的包名
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.inanter.remoteboot">
//系统说明名细(在桌面的显示图标及APP名称等)
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
//默认系统启动显示的活动窗口
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
//被H5启动后,APP呈现的活动窗口
<activity android:name=".SecondActivity">
<intent-filter>
//告诉系统这是一个呈现数据的活动窗口
<action android:name="android.intent.action.VIEW" />
//默认添加的category
<category android:name="android.intent.category.DEFAULT" />
//允许通过浏览器的方式打开此活动窗口
<category android:name="android.intent.category.BROWSABLE" />
//打开此窗口的scheme协议格式
<data android:host="yanxiaobo.com" android:scheme="inanter" />
</intent-filter>
</activity>
</application>
</manifest>
APP通过注册清单将所有Activity活动窗口的信息告知系统,当系统接收到跳转页面指令后,会检查所管理的activity,根据intent-filter过滤器指令的条件进行筛选,如果选中一个则直接打开对应的APP活动窗口,如果选中多个,系统则会弹出列表让用户选择。