Code example for Field

Methods: get, setAccessible

0
 
  private static Object getDeclaredField(Object obj, String name)
      throws SecurityException, NoSuchFieldException, IllegalArgumentException, 
      IllegalAccessException { 
    Field f = obj.getClass().getDeclaredField(name);
    f.setAccessible(true);
    Object out = f.get(obj);
    // System.out.println(obj.getClass().getName() + "." + name + " = "+ 
    // out); 
    return out;
  } 
 
  public static Object getRequestQueue(Context ctx) throws Exception {
    Object ret = null;
    Class networkClass = Class.forName("android.webkit.Network");
    if (networkClass != null) {
      Object networkObj =
          invokeMethod(networkClass, "getInstance", new Object[] { ctx }, Context.class);
      if (networkObj != null) {
        ret = getDeclaredField(networkObj, "mRequestQueue");
      }