博客出自:http://blog.csdn.net/liuxian13183,转载注明出处! All Rights Reserved !
这个问题解决了两天时间,因为网上没有完整的解决方案,解决后分享一下给大家!
解决这个问题有两个作用:
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
热度:93 发布时间:2016-04-28 00:44:12.0
相关解决方案
- android 读取byte[]中的元素解决方案
- android 标题栏兑现方式
- android 中Activity向BroadcastReceiver发送数据,该怎么解决
- Android 4.0 为什么模拟器老是提示小弟我谷歌拼音输入法已停止
- android:getSharedPreferences() 这是哪个类的方法解决思路
- android 怎么判断一个程序是否联网
- android 大量数据按周分组,该如何解决
- android RadioButton如何设置默认选中
- ksoap2-android-这个包,连接webService怎么设置超时
- android 怎么重新设置锚点
- android UI界面设计解决方案
- android 图片对象获取的有关问题
- android 怎么调用淘宝支付宝接口
- Android 沿袭InputMethodService自定义输入法
- android 关于服务连接的疑义
- android 两个activity如何通信
- android 怎么实现对view的放大和缩小
- android 教程解决方法
- android ID,该如何处理
- 准备复习2-3个月,看java+android,请问有经验者,怎么看效果最好》
- android UI线程与AsyncTask的有关问题
- android(java)中的java.net能不能和c#的system.net.sockets进行tcp通信,该如何解决
- android ListView 中的onItemClick Intent 没法跳转
- android(java) 中文乱码的有关问题
- c#c++,android,ios(iphone),php,java视屏课程 散分
- android Post文件到ASP.NET的有关问题,能收到参数收不到文件
- RIM 替 Android 开发者提供免费的 PlayBook!2月13日前
- android 动态设立控件高度
- Android test project 编译方法
- android -相机使用教程(1)解决方法