Getting class by its name

android, class, java

Solution

use forName instead..

something like this..

 try {
    Class<?> act = Class.forName("com.bla.TestActivity");
 } catch (ClassNotFoundException e) {
        e.printStackTrace();
}

Problem

If I have an Activity class called TestActivity in my application, is there a way to get its class by its name like in this example: ``` Class<?> c = getClassByName("TestActivity"); ```

Original source