Вопрос

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?

Это было полезно?

Решение

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
   }
 }

Declare in the manifest only the activities that user can see during its experience. Usually these are called by intents. The others you should declare abstract.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top