I know you must declare all your Activities and Services in the AndroidManifest.xml file in order to make them accessible to the system (as said in the official docs) but if I have a Service or an Activity that I want to be started only by another Activity in my app, do I need to declare it in the manifest? I.e., I always launch a secondary activity from the primary activity of my app that directly points the secondary activity’s class (no intent filter resolution), is still necessary to declare the secondary activity in the manifest? And what if I don’t want anyone outside my app to be able to launch my secondary activity? I’m sorry if it is a stupid question, I just want to understand if it is a good practice (if possible) to omit activities and services from the manifest file when you want them to be started only by pointing their respective classes within the same app.
I know you must declare all your Activities and Services in the AndroidManifest.xml file
Share
You must declare all of your activities and services (and everything else like BroadcastReceivers) in the AndroidManifest.xml file.
You won’t be able to use them otherwise.
EDIT: As per CommonsWare comment, adding android:exported=”false” to the AndroidManifest.xml’s declaration of the activity would prevent your secondary activity from being launched outside of your application.