Whenewer I want to start new activity, I use this code:
Intent myIntent1 = new Intent(this, Info1.class);
startActivity(myIntent1);
But, what about the case, I am getting class name from String Array? I have tried method class.forName like this:
Intent intent = new Intent(this, Class.forName(array[1]));
startActivity(intent);
But no success. It is giving me error of
java.lang.ClassNotFoundException: Info1 in loader
dalvik.system.PathClassLoader
even though in first case it started an activity successfully. I have to add that I am 100% sure array[1] contains string “Info1” and that I have Info1.class in my package.
Do you know, how to solve this?
The method
Needs fully qualified name which means you should give the name along with the package details(in which package the class exists)
as an example
Documentation Reference here