Android examples for java.lang.reflect:Inner Class
get Inner Class Instance
//package com.java2s; import java.lang.reflect.Constructor; public class Main { public static Object getInnerClassInstance(Class clazz, boolean isPublicConstructor, Class constructorArgsTypes[], Object constructorArgs[]) throws Exception { return getClassInstance(clazz, isPublicConstructor, constructorArgsTypes, constructorArgs); }//from w ww. java 2 s . co m public static Object getClassInstance(Class clazz, boolean isPublicConstructor, Class constructorArgsTypes[], Object constructorArgs[]) throws Exception { Constructor constructor; if (isPublicConstructor) constructor = clazz.getConstructor(constructorArgsTypes); else constructor = clazz .getDeclaredConstructor(constructorArgsTypes); if (!constructor.isAccessible()) constructor.setAccessible(true); return constructor.newInstance(constructorArgs); } }