Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I HAVE to declare every activity in a manifest file?

I want to create an Activity but not have to declare it in the manifest file. Is this possible? Everywhere I've seen it seems that every activity must be declared in the manifest, yet I notice that some activities, such as the built-in ChooserActivity, is not declared in my manifest file.

like image 430
Gadzair Avatar asked Dec 12 '13 00:12

Gadzair


2 Answers

Short answer: yes, every Activity in your application must be declared in the manifest. As described in the Android docs, the purpose of the manifest (among other things) is:

It describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities (for example, which Intent messages they can handle). These declarations let the Android system know what the components are and under what conditions they can be launched.)

http://developer.android.com/guide/topics/manifest/manifest-intro.html#ifs

Therefore any Activity class in your application must be defined in your Manifest. The same goes with Intents, Services etc. even if those components aren't accessible from outside of your application.

As for ChooserActivity and any other Activity which you didn't define in code, they will have their own definitions in another Manifest. If for whatever reason you decide to subclass an existing Activity outside of your application, then you will have to define it in your Manifest too.

like image 195
TheIT Avatar answered Sep 22 '22 07:09

TheIT


I want to create an Activity but not have to declare it in the manifest file. Is this possible?

No, sorry.

I notice that some activities, such as the built-in ChooserActivity, is not declared in my manifest file

That activity is not part of your application. It is part of the core operating system.

like image 30
CommonsWare Avatar answered Sep 21 '22 07:09

CommonsWare