tyb
tyb

Reputation: 4749

Declaring classes in AndroidManifest.xml

I understand that, in Android, all activities must be declared within the manifest. Is this true to all .java files in the project?

I have a few classes that aren't activities (not directly related to an UI) and i'm unsure whether I need to declare them in the manifest.

Thanks!

Upvotes: 2

Views: 3589

Answers (4)

Fuzzical Logic
Fuzzical Logic

Reputation: 13015

Angelo,

To answer your question, you must declare any class that is a static Android Application Component. This means all Activities, ContentProviders, and Services. This also includes static BroadcastRecievers that are not manually registered in code. Finally, you must also declare any external Android Library Projects.

The idea is essentially this: If you want the System or User or External Application to be able to use your object, it must be declared. Anything that has a UI (i.e. Activity) is a given in there... BroadcastRecievers are the most flexible in this regard, as they can be built, registered, and enabled dynamically. However, they will only run if the application is running, if created in this manner.

Hope this helps,

FuzzicalLogic

Upvotes: 1

J. Maes
J. Maes

Reputation: 6892

No, only activities. All other java classes don't have to be declared in the manifest file to be used. If you're having contentproviders or services in your application you also need to declare them in the manifest file.

Upvotes: 7

clement
clement

Reputation: 4266

Don't do that, it is false! you only just have to put some informations like ContentProviders and Authorisations

Upvotes: 1

Jan-Henk
Jan-Henk

Reputation: 4874

You don't have to declare all classes in the manifest. Things you do need to declare are Activities, Services and ContentProviders.

Upvotes: 2

Related Questions