I am trying to create an Activity
class from a string and pass it to a static method. I found this on SO to pass a string into a class. FirstActivity
is already created.
SecondActivity
String myClass = "com.package.FirstActivity";
Class<?> myClass = Class.forName(myClass);
//this works
//Intent myIntent = new Intent(getApplicationContext(), myClass);
//I want to pass to a static method, but it gives a error. Class cannot cast to Activity
StaticMethod.processThis(myClass , "test");
StaticMethod
public static void processThis(Activity contextActivity, String str) {
//do processing
}
How can I get processThis
to work? If I understand correctly, an Activity
is also a class?