To understand the statement
private final Class<? extends FragmentActivity> activityClass;
and the corresponding constructor parameter, remember that Object has a getClass() method:
public final Class<?> getClass();
Alternatively, if you have a named type (without an anonymous subclass), you can use .class :
String s = "a string"; assert s.getClass().equals(String.class);
There are several places where you use this mechanism. Reflection is one, albeit rare. Log4J loggers is different.
The safest way to declare an arbitrary object class is:
Thing t = ...; // assume not null. Class<? extends Thing> clazz = t.getClass();
After all, t may be an instance of the Thing subclass, and possibly even an anonymous subclass. This expression means that clazz is a Class object, and a particular variable of type clazz is some, not necessarily known, subclass of Thing or maybe only Thing .
Returning to the original expression, activityClass is a class object for a FragmentActivity or some subtype. And a program can build an instance using Class.newInstance() if it has a constructor with 0 arguments.
source share