Android之Intent 序列化反序列化
2016-05-14 16:17
417 查看
我们做截屏功能的时候,因为有2个进程,本来是把intent和MediaProjection放到Application里面,但是由于跨进程了,所以数据拿不到,就采用了Parcel 序列化出错,未找到出错的原因,找其它的解决方法:
查看Intent 的源代码, 发现类中已经实现序列化功.
序列化
intent.toURI();
反序列 化使用:
Intent.parseUri(uriString, 0);
先看序列化:
intent.toURI();
Intent intent = new Intent("cn.eben.bookshelf.VIEW");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String intnetUri = intent.toURI();
//序列化后:
//#Intent;action=cn.eben.bookshelf.VIEW;launchFlags=0x10000000;end
反序列 化使用:
Intent.parseUri(uriString, 0);
查看Intent 的源代码, 发现类中已经实现序列化功.
序列化
intent.toURI();
反序列 化使用:
Intent.parseUri(uriString, 0);
先看序列化:
intent.toURI();
Intent intent = new Intent("cn.eben.bookshelf.VIEW");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String intnetUri = intent.toURI();
//序列化后:
//#Intent;action=cn.eben.bookshelf.VIEW;launchFlags=0x10000000;end
反序列 化使用:
Intent.parseUri(uriString, 0);
Intent i; ry { i = Intent.parseUri(uriString, 0); context.startActivity(i); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); }
相关文章推荐
- Android之用SingleTask和TaskAffinity解决手机截取的项目启动页面问题
- 大量 Material Design 学习资源
- android中关于位移动画TranslateAnimation开始和结束时闪动问题的记录
- android-----带你一步一步优化ListView(一)
- Android中的Rect类——奇葩的思维
- android:width与android:layout_width的区别
- 第一章:Android概论解析
- Android Studio安装
- Android AutoLayout自适应的适配方式
- Android数据存储方式
- AndroidStudio设置SVN版本控制工具
- 收集android上开源的酷炫的交互动画和视觉效果:Interactive-animation
- Android 自定义SnakeBar
- 【转】Google推荐的命名规则——Android图片资源
- Android 一键生成Parcelable
- Ubuntu 12.10编译Android 4.0.3的常见错误
- Android 自定义checkbox样式
- 安卓绘制圆形图片
- android中加载本地图片到内存
- Android笔记hm002