I have my own base abstract class which extends Activity class.
public abstract class BaseActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutResourceId());
}
protected abstract int getLayoutResourceId();
}
public class Activity1 extends BaseActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// do extra stuff
}
@Override
protected int getLayoutResourceId() {
return R.layout.layout_for_activity1;
}
}
My base class BaseActivity is not registered in the Manifest file and I do not get any error.
Is this a time bomb (not registering base class in Manifest) or this is the way it should be? Can someone explain why?
According to the docs, the
<activity>on the manifest:Think about it like this: If there’s an activity (any class that extends
Activityor a class that extends it) that you will navigate to at some point in your application, it needs to be declared in the manifest. Regardless of how you reach that activity. This excludes classes that only extend theActivityclass but you can’t reach directly.Source