android 反射 记录

private static String audioParse(byte[] msgData) {
    try {
       // Object o = BUtils.getObj(msgData);
        Class<?> cls = Class.forName("localpb.richMsg.RichMsg$PicRec");
        Object haha = cls.newInstance();

        //if (cls.isInstance(o)) {
            Method method = cls.getMethod("mergeFrom", byte[].class);
            method.invoke(haha, msgData);
            Field f =cls.getDeclaredField("rawMsgUrl");
            Object local = f.get(haha);
            f.setAccessible(true);
            android.util.Log.e(TAG, "type:"+f.getClass()+"22name:"+f.getName()+">>>"+f.getType() +"hh:"+f.get(haha));
        Class<?> cls11 = Class.forName("com.tencent.mobileqq.pb.PBStringField");
        Field ll = cls11.getDeclaredField("value");
        ll.setAccessible(true);
        String ls = (String) ll.get(local);
        android.util.Log.e(TAG,"************ly*****************"+ls);
        Field fields[]=f.getClass().getDeclaredFields();//获得对象所有属性
        Field field=null;

        for (int i = 0; i < fields.length; i++) {
            field=fields[i];
            field.setAccessible(true);//修改访问权限
            android.util.Log.e(TAG, "lt:"+field.getName());
            //android.util.Log.e(TAG, "lt:"+field.get(f));
        }
        Method mm[]=f.getClass().getDeclaredMethods();
        Method m=null;
        for (int i = 0; i < mm.length; i++) {
            m=mm[i];
            m.setAccessible(true);//修改访问权限
            android.util.Log.e(TAG, "lt:"+m.getName());
            Class<?>[] parameterTypes = m.getParameterTypes();
            for (Class<?> clas : parameterTypes) {
                String parameterName = clas.getName();
                System.out.println("参数名称:" + parameterName);
            }
            android.util.Log.e(TAG,"*****************************");
        }
        Class<? extends Field> ttt = f.getClass();
        Method m1 = ttt.getDeclaredMethod("get", Object.class);
        m1.setAccessible(true);
        String llr = (String) m1.invoke(f,f);
        android.util.Log.e(TAG, "llr:"+llr);
            //return tmp;
        //}
    } catch (Throwable e) {
        ZNativeCall.e(e);
    }
    return null;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值