I have a base activity from which I subclass several other activities.
Those other activities I do register in the manifest so I can use them from within my application.
However, Android inspection says, for my base activity, "Activity not registered in the manifest"
.
I see no reason to register the base activity as I never use it directly. However, maybe, I am missing something and the warning should not be ignored?
Why this warning anyway?
Goto your Android Manifest , goto the Applications Tab (at the bottom), click on "Add", Choose Activity. On the right, next to Name: Click on Browse , to get a list of available activities, just add it and you're set! :) You could right way just edit the Manifest XML aswell. It's upto you.
The Android Manifest is an XML file which contains important metadata about the Android app. This includes the package name, activity names, main activity (the entry point to the app), Android version support, hardware features support, permissions, and other configurations.
In the manifest file, you use the <intent-filter> tag to make intent to app components. For example, you can see below the intent filter for activities.
You'll only need to list activities that are entry points to your app in the manifest. That is, activities that are invoked with an Intent
.
You should not have activities that are in fact not instantiable entry points. Make such activity classes abstract
. This will also get rid of the lint warning.
You should make your BaseActivity as an Abstract class. No need to register such Activities in manifest, they are just simple java classes extending Activity class not an Activity of your application.
public abstract class BaseActivity extends Activity {
@Override
public void onCreate(bundle) {
super.onCreate(bundle);
setContentView(getLayoutResourceId());
}
protected abstract int yourmethods();
}
public class Activity1 extends BaseActivity {
@Override
public void onCreate(bundle) {
super.onCreate(bundle);
// do extra stuff on your resources, using findViewById on your layout_for_activity1
}
@Override
protected int yourmethod() {
//implemetation
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With