Android怎样从外部跳进App
解决问题有两个作用:
1、不用打开App直接进入某页面
2、实现App分享到外部,同一时候由外部进入App的闭环。
这个话题能够分双方面来讲。一方面是从微信进入App,还有一方面是从网页进入App。
咱们拿http://my.oschina.net/liucundong/blog/354029当样例来讲一下
主要通过scheme、host、path、pathPrefix等data信息来区分
两个方案都须要给跳转到的Activity增加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="cundong" android:host="splash"/>
</intent-filter>
首先我们来讲微信端进入App,场景:从App分享内容到微信,再从微信直接打开App。
第一步,注冊微信公众平台,相关企业信息,下载链接,Logo等 都填写完成
第二步,分享时使用WXAppExtendObject,把链接url赋值给extInfo
第三步,在IWXAPIEventHandler接口的onReq方法的req.getType()=ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX时,发起你的跳转
第四步。跳转时须要数据,数据从哪里来。从WXEntryActivity类中onCreate方法的getIntent对象里来
从微信进入App就这样结束了。
-------------------我是切割线------------------------
接着来讲网页端,因为webView的限制。如微信、微博等都採用这个控件。所以仅仅能分享到网页。再进入App。
原理例如以下:
<div>
<a id="J-call-app" href="javascript:;" class="label">马上打开>></a>
<input id="J-download-app" type="hidden" name="storeurl" value="http://apk.hiapk.com/appinfo/com.tmall.wireless">
</div>
<script>
(function(){
var ua = navigator.userAgent.toLowerCase();
var t;
var url=document.location;
var config = {
/*scheme:必须*/
scheme_IOS: 'cundong://',
scheme_Adr: 'cundong://splash',
download_url: document.getElementById('J-download-app').value,
timeout: 600
};
function openclient() {
var startTime = Date.now();
var ifr = document.createElement('iframe');
//alert(config.scheme_Adr);
ifr.src = ua.indexOf('os') > 0 ? config.scheme_IOS : config.scheme_Adr;
ifr.style.display = 'none';
document.body.appendChild(ifr);
var t = setTimeout(function() {
var endTime = Date.now();
if (!startTime || endTime - startTime < config.timeout -200) {
window.location = config.download_url;
} else {
window.location.href=ifr.src.replace("http://","cundong://");;
}
}, config.timeout);
window.onblur = function() {
clearTimeout(t);
}
}
window.addEventListener("DOMContentLoaded", function(){
document.getElementById("J-call-app").addEventListener('click',openclient,false);
}, false);
})()
</script>
点击打开四个字后,运行一个js,在限制时间内。假设能够打开App则打开,否则进入下载页
解决问题的基本思路就是这样。欢迎大家交流探讨!
Android怎样从外部跳进App的更多相关文章
- Android如何从外部跳进App
博客出自:http://blog.csdn.net/liuxian13183,转载注明出处! All Rights Reserved ! 这个问题解决了两天时间,因为网上没有完整的解决方案,解决后分享 ...
- Android - 分享内容 - 给其他APP发送内容
创建一个intent时,必须要指定intent将要触发的操作.Android定义了很多操作,包括ACTION_SEND,就象可以猜到的一样,表示intent是把数据从一个activity发送给另一个, ...
- Android M新特性之APP Link
The Android M Developer Preview introduces support for App Links, which improves upon existing link ...
- Android Studio 导入外部lib文件
Android Studio 导入外部lib文件 1.将jar包放入Module里的lib文件夹中.(自己创建lib文件夹) 2.在project选中jar包点击右键"Add as li ...
- 介绍开发Android手持终端PDA盘点APP软件
介绍开发Android手持终端PDA盘点APP软件 软件需要自动识别我导入的TXT格式或者excl格式的盘点表,然后自动生成一个复盘数据,做AB比对,界面上需要显示的有总数量,单品数量,条码,编码,商 ...
- 关于android源码中的APP编译时引用隐藏的API出现的问题
今天在编译android源码中的计算器APP时发现,竟然无法使用系统隐藏的API,比如android.os.ServiceManager中的API,引用这个类时提示错误,记忆中在android源码中的 ...
- Android - 分享内容 - 接收其他APP的内容
就象程序可以发送数据给其他程序,所以也可以接收其他程序的数据.想一下用户如何和程序交互,以及想从其他程序接收什么样类型的数据.例如,一个社交程序可能对接收其他程序的文字(比如有趣的网址)感兴趣.Goo ...
- Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app
出现的问题: Error:Execution failed for task ':app:preDebugAndroidTestBuild'.> Conflict with dependency ...
- 解决Ubuntu 16.04 上Android Studio2.3上面运行APP时提示DELETE_FAILED_INTERNAL_ERROR Error while Installing APKs的问题
本人工作环境:Ubuntu 16.04 LTS + Android Studio 2.3 AVD启动之后,运行APP,报错提示: DELETE_FAILED_INTERNAL_ERROR Error ...
随机推荐
- 优动漫PAINT画树教程
依次解析画树要点!让画树不再是难事~ 优动漫PAINT下载:http://wm.makeding.com/iclk/?zoneid=18597
- servlet中Cookie的编码问题
a.什么是Cookie的编码问题? Cookie只能存放合法的ascii字符,如果是非asicc字符(比如中文), 需要转换成合法的ascii字符的形式. b.如何处理? ...
- Linux下编译,安装Apache httpd服务器
环境:ubuntu 16.0.4 Apache官网下载Apache httpd压缩包:httpd-2.4.27.tar.gz,安装之前请确定安装了make工具,我安装的是GNU make 解压文件 s ...
- 转载git的使用
版权声明:本文为博主原创文章,未经博主允许不得转载.转载请注明原地址 转载请注明出处!谢谢 1.安装Git:Ctrl + Alt + T使用终端:使用命令 [plain] view plain cop ...
- shell 整数
[] (())和[[]] -eq == 或= -ne != -gt > -ge >= -lt < -le <= [root@web02 ~ ...
- Docker yum 安装
[liwm@Eren ~]$ sudo su[root@Eren liwm]# yum install -y docker 已加载插件:fastestmirror, langpacks, prod ...
- Majority Element:主元素
Given an array of size n, find the majority element. The majority element is the element that appear ...
- CF 558D(Guess Your Way Out! II-set解决区间问题)
D. Guess Your Way Out! II time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- java学习记录笔记--继承,super,Object类
继承: Java中的继承是单继承的. 1.子类拥有父类的全部属性和方法. 可是属性和方法的修饰符不能使private. 2.能够复用父类的代码. 方法的重写须要满足的条件: a.返回值类型 b.方法名 ...
- springboot shiro配置
导入相关包(这里配合使用Ehcache缓存) <dependency> <groupId>org.apache.shiro</groupId> <artifa ...