Android examples for java.lang.reflect:Class
is one class Assignable From another class
import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import android.util.Log; public class Main{ private static final String TAG = ParcelUtils.class.getSimpleName(); public static boolean isAssignableFrom(Class<?> cls, String asgnName) throws IllegalArgumentException { return cls.isAssignableFrom(forName(asgnName)); }//from w w w . java 2s . c om public static Class<?> forName(String className) throws IllegalArgumentException { try { return Class.forName(className); } catch (ClassNotFoundException e) { Log.e(TAG, "Illegal access when unmarshalling: " + className, e); throw new IllegalArgumentException( "ClassNotFoundException when unmarshalling: " + className); } } }