2017.6.26 工作记录

Android 中传参数的时候经常需要传参数,有时候参数需要通过bundle进行传递,但每次都要写如下显得非常麻烦

Bundle bundle = new Bundle();
bundle.putSerializable("key2",...);
bundle.putString("strKey",...);
bundle.putInt("intKey",...);

所以我就写了个工具类中使用的方法,只需传参数就可以了,方法暂时只支持String,int,boolean,实现接口的Serializable和Parcelable,欢迎使用这个方法

public static ArrayList<String> bundleKeys;
    /**
     * 获取Bundle
     * @param objs
     * @return
     */
    public static Bundle getBundle(Object... objs){
        Bundle bundle = new Bundle();
        String key = "";
        bundleKeys = new ArrayList<>();
        for(int i = 0; i< objs.length ;i++){
            key = "obj"+(i+1);
            bundleKeys.add(key);
            if(objs[i] instanceof Integer){
                bundle.putInt(key, (Integer) objs[i]);
                continue;
            }
            if(objs[i] instanceof String){
                bundle.putString(key, (String) objs[i]);
                continue;
            }
            if(objs[i] instanceof Boolean){
                bundle.putBoolean(key, (Boolean) objs[i]);
                continue;
            }
            if(objs[i] instanceof Serializable){
                bundle.putSerializable(key, (Serializable) objs[i]);
                continue;
            }
            if(objs[i] instanceof Parcelable){
                bundle.putParcelable(key, (Parcelable) objs[i]);
                continue;
            }
        }
        return bundle;
    }

使用方法:Util.getBundle("string",true,2);

解析端:

String str = getIntent().getExtras().getString(Uril.bundleKeys.get(0));
Boolean bool = getIntent().getExtras().getBoolean(Uril.bundleKeys.get(1))
int num = getIntent().getExtras().getInt(Uril.bundleKeys.get(2))
时间: 2024-08-06 16:33:12

2017.6.26 工作记录的相关文章

2017/07/26 工作日志

第二天一早应该是从请教前辈开始的,先问了任务相关的问题,开始有大致的框架,然后向另一个前辈了解TFS的用法,在这一过程中发现了之前部署IIS的一个问题:部署多个网站效率太低.其实只要新建一个网站,然后再这个网站里使用"添加应用程序"选择相应的物理路径就可以,通过相应的应用程序的名字就可以访问网站,并且在这一网站下的应用程序都使用同一个应用程序池,这样的话,设置也只需一次. 下午经理正好坐在旁边,问到了指派任务的报表问题,知道了公司有报表专用的项目,又去部署这个项目.遇到了类库引用的问题

团队作业4——第一次项目冲刺(Alpha版本)2017.4.26

2017.04.26 天气热. 时间:上午 9:35 ---10:10分 地点:陆大304实验室 会议内容:今天将昨天的的一些问题进行了讨论,以及针对助教提出的问题进行了分析,是因为我们昨天经过讨论后在任务中又加上了一些细节,导致了任务又多了一点点.随着时间的临近,项目Alpha版本即将截止,今天小组成员对任务有又进行了确认,齐心协力完成我们的任务. 1:每日讨论图片(拍摄者小组成员 黄睿) 2.任务分解图: 3.任务分配: 今天的整体分工如下: 武健男:负责今天的博客编写: 林俊鹏:询问实验室

工作记录

 20140428  6 20140505 9 20140512 4 20140519 11 20140526 8  20140429  5 20140506 10 20140513 6 20140520 10 20140527 11  20140430  6 20140507 14 20140514 7 20140521 10 20140528 9 20140501 6 20140508 4 20140515 9 20140522 10 20140529 11 20140502 5 20140

[工作记录] Android OpenSL ES: references &amp; AAC related

AAC V.S. MP3 http://en.wikipedia.org/wiki/Advanced_Audio_Coding#AAC.27s_improvements_over_MP3 AAC patent lisense FAQ: http://www.vialicensing.com/licensing/aac-faq.aspx you may need a license but usually no fees, exept that when end user products are

[工作记录] Android OpenGL ES: non-square texture - continue

previous: [工作记录] Android OpenGL ES 2.0: square texture not supported on some device recently I found that it is the mipmap of a non-square texture that cause the black texture problem: http://stackoverflow.com/questions/5052762/using-mipmaps-results-

工作记录 - OBB的解决方案

之前关于OBB的内容: Android上使用native IO 最近工作中的问题笔记 工作记录[续] android OBB 自从用了Java来mount OBB, 再也没有遇到挂载的问题. 但最近在LG Nexus5 和LG G2上测试, 发现某个大约30K文件的文件, 一次性读取出来以后, 处理会报错. 最后排除各种因素, 比如为了排除buffer坏掉的因素,读的时候单独new一个新buffer,一次性读取,然后dump到sd卡.对比dump出的文件, 发现整个文件中间有n个字节(大约是32

【工作记录】c#操作win7注册表

这里讲一 C# 小列子(高手请绕过此地! ), 我们平时都是在xp开发比较多...不过现在很多开发人员也在win7下开发了. 下面是在 LocalMachine 下的 一下注册表操作 ,就不详说了 private static void DeleteRegistry(string name){string[] aimnames;RegistryKey hkml = Registry.LocalMachine;RegistryKey software = hkml.OpenSubKey("SOFT

201404-20151119工作记录

20140417-20151119 工作记录 =======================改科室BUG20140416 入职2014041720140418 下午忘了打卡 周五======================= =======================2014042120140422201404232014042420140425======================== ========================材料分析 20140428201404292014

python的工作记录A

马上进入工作自动化: [[email protected] ~]# cat svn_bbs.py import os,sys,commands,subprocess import re,time svnUrl = "svn://xxx" svnExportCmdPre = "svn export svn://xxx/" sitePath = "/xxx" updateFolder = "/srv/salt/xxx/" salt