启动一个应用,有很多种,今天说的,就是其中的一种.
- 第一步: 想要启动APP,需要在应用的清单文件中配置:下面是一个默认配置:
<intent-filter>
<data android:scheme="xxxxxx" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
只需要,把上面的一行代码加入到AndroidManifest.xml 文件的 你想要启动 activity 节点下,即可,其中,scheme 为约束名称,尽量唯一性,可用包名.
- 第二步: 在需要的html 网页位置,添加一个超链接:
<a href="xxxxxx://useful_info_for_anton_app">启动应用</a>
xxxxxx 和AndroidManifest.xml 定义的scheme保持一致.
通过上面的就可以简单的通过一个网页链接来启动一个应用了.
注:上面的html 里超链接里的:// 后面的数据,可以在启动的activity中通过getIntent().getData()来获取到,更详细的介绍 点此.