上次遇到 Intent 使用用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 i;
try {
i = Intent.parseUri(uriString, 0);
context.startActivity(i);
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
简单方便.
解决上次的问题.

本文介绍了一种解决Intent序列化错误的方法,通过使用Intent自带的toURI()方法进行序列化,然后利用parseUri()方法完成反序列化,这种方法简单有效。
9462

被折叠的 条评论
为什么被折叠?



