I have a little problem. I want to start activity but in something other way. I know that
Intent i = new Intent(this, ActivityTwo.class);
Just use....
Intent intent = new Intent().setClassName(activity,"packageName"+"className");
startActivity(intent);
Class<?> c =Class.forName("YOUR STRING" );
Intent intent = new Intent(FirstActivity.this, c);
startActivity(intent);
Try this:
startActivity(this, Class.forName(yourStringClass));
You can look up a Class
by name using Class.forName("MyString")
Here is a code by which you can start activity using the name of the activity
Class<?> c = null;
if(StringClassname != null) {
try {
c = Class.forName(StringClassname );
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Intent intent = new Intent(mail.this, c);
startActivity(intent);
Here class name will be full name of the class with the package name. For example if your package name will be x.y.z and if you have Activity name called A then the full name of the Activity A will be x.y.z.A.