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 ...
随机推荐
- 函数式编程-只用"表达式",不用"语句"()
把函数当作普通的运算符使用. 2. 只用"表达式",不用"语句"() "表达式"(expression)是一个单纯的运算过程,总是有返回值: ...
- k8s使用ceph存储
目录 ceph配置 k8s 配置 通过静态pv,pvc使用ceph 测试多pod挂载静态pv数据不一致问题 StoragaClass 方式 ceph 常用命令 k8s 常用命令 k8s各类端口及IP说 ...
- ActiveMQ服务安装
1.下载安装ActiveMQ服务提供者 http://activemq.apache.org/ 2.启用ActiveMQ服务 cd [activemq_install_dir] bin\activem ...
- redhat7.5 升级OpenSSH_7.8p1
1:拷贝编译好rpm安装包 [root@liwm ~]# scp -r root@192.168.31.130:/home/openssh7.8 /home/ root@192.168.31.130' ...
- POJ 1975 Median Weight Bead
Median Weight Bead Time Limit: 1000ms Memory Limit: 30000KB This problem will be judged on PKU. Orig ...
- Android5.0以上系统的移动网络开关
笔者近期遇到一个非常有意思的bug,贴出来和大家分享下. 那是一个温暖的早晨,阳光晒得人非常舒服.一封bug邮件像一片叶子飘到我的邮箱. 一番交流.笔者确认负责的Widget开关在Android5.0 ...
- vue2.0 路由学习笔记
昨天温故了一下vue2.0的路由 做个笔记简单记录一下! 1.首相和vue1.0一样 要使用vuejs的路由功能需要先引入vue-router.js 2.然后修改原有a标签处代码 这里以一个ul li ...
- 安卓4.3以上版本已经完美支持BLE(英文版)
Android 4.3 (API Level 18) introduces built-in platform support for Bluetooth Low Energy in the cent ...
- spark 类标签的稀疏 特征向量
一个向量(1.0,0.0,3.0)它有2中表示的方法 密集:[1.0,0.0,3.0] 其和一般的数组无异 稀疏:(3,[0,2],[1.0,3.0]) 其表示的含义(向量大小,序号,值 ...
- 针对发起alter tablespace test begin backup 断电情况的处理
SQL> select tablespace_name from dba_tablespaces; TABLESPACE_NAME ------------------------------ ...