Android examples for java.lang.reflect:Class
Load Class by name
import android.util.Log; public class Main { public static final String TAG = Main.class.getSimpleName(); public static Class<?> LoadClass(String className) { Class<?> result = null; Log.d(TAG, "Attempting to load call: " + className); ClassLoader classLoader = Main.class.getClassLoader(); try {// w w w . j a v a 2 s . c om result = classLoader.loadClass(className); Log.d(TAG, "Class loaded"); } catch (ClassNotFoundException ex) { Log.d(TAG, "Class failed to load"); Log.d(TAG, ex.getMessage()); } return result; } }