Android examples for java.lang.reflect:Field
copy All Instance Fields from one Instrumentation object to another Instrumentation
//package com.java2s; import android.app.Instrumentation; import java.lang.reflect.Field; public class Main { public static boolean copyAllInstFields(Instrumentation src, Instrumentation target) { if (src == null || target == null) { return false; }//from w w w .jav a 2 s. c o m Class<?> clsType = Instrumentation.class; while (clsType != null) { Field[] fields = clsType.getDeclaredFields(); for (Field fid : fields) { try { fid.setAccessible(true); Object ref = fid.get(src); fid.set(target, ref); } catch (Exception e) { e.printStackTrace(); } } clsType = clsType.getSuperclass(); } return true; } }