Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activity not registered in the manifest Lint warning

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?

like image 540
Alexander Kulyakhtin Avatar asked Jan 12 '14 10:01

Alexander Kulyakhtin


People also ask

How do I register activity in manifest?

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.

What is the activity manifest Android?

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.

Which tag is used to declare an activity in the manifest file?

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.


2 Answers

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.

like image 167
laalto Avatar answered Sep 17 '22 08:09

laalto


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
   }
 }
like image 37
Piyush Agarwal Avatar answered Sep 18 '22 08:09

Piyush Agarwal