Always declare actions and services in an AndroidManifest file?

I know that you must declare all your actions and services in the AndroidManifest.xml file in order to make them available for the system (as indicated in the official documents), but if I have a Service or Activity that I want to start only with another action in my application, do I need to declare it in the manifest? Ie, I always start secondary activity from the main activity of my application, which directly indicates the secondary activity class (without permission of the intent filter), still need to declare secondary activity in the manifest? And what if I don't want anyone from my application to be able to start my secondary activity? I'm sorry if this is a stupid question, I just want to understand if it is good practice (if possible) to omit actions and services from the manifest file whenever you want,so that they run by specifying their respective classes within the same application.

+3
source share
1 answer

You must declare all your actions and services (and everything else, like BroadcastReceivers) in the AndroidManifest.xml file. You cannot use them otherwise.


EDIT: as per CommonsWare comment, adding android: exported = "false" to the AndroidManifest.xml declaration of this action will prevent your secondary activity from starting outside your application.

+5
source

All Articles