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.
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
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.
I want to create an Activity but not have to declare it in the manifest file. Is this possible?
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.