Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Android Intent 序列化反序列化

上次遇到 Intent 使用用Parcel 序列化出错(见 http://www.linuxidc.com/Linux/2014-02/96336.htm),未找到出错的原因,因项目急. 找其它的解决方法:查看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();
        }简单方便.解决上次的问题.更多Android相关信息见Android 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=11