首先要知道对四大组件的调用分两种
显示调用
隐式调用
显示调用就是 startactivity 或者startactivityforresult 需要指定 跳转方
通过链接启动就是显示调用
这里采用 配置
通过配置activity的 intent-filter
category ,action data 来实现目的
以下是配置代码
data配置的是启动的地址,服务器端需要相应的配置此地址
其实data还可以配置很多东西
比如 part端口号 ,或者host主机名
还有携带的参数
<intent-filter>
<data android:scheme="investors"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
在app想要被回掉的页面 manifest 里面添加如上代码就可以了
接下来是服务器的配置
在这里采用的是 jsp的方式
例如一些比较操蛋的需求 分享后点击链接跳转app相应地址,或者下载app 这样的配置就可以
启动也有两种方式
第一种是跳转到页面以后 点击超链接才能启动app
第二种是访问链接 直接启动app
以下代码是直接启动app
注掉的是第一种方式的实现
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This is my JSP page. <br>
<!-- <a href="investors://"> 某个操蛋的</a> -->
<script>
location.href="investors://"
</script>
</body>
</html>
本篇博客结束
如果觉得对你有帮助
粉我把
关注更多我的blog.
技术交流群:
博客圈 493554215
这是一个热爱分享技术,拥有热烈学习氛围的群 ,
博主身为群内的一员感到骄傲
推荐还在路上的伙伴们
想看更多的来 楼主的博客平台
很多私货哦
http://www.guhaotechnology.com