Reputation: 49097
I am making an application where I am using some base activities that I inherit things from. I tried running the application without adding these activities to the manifest file, and it works. But should I add them or leave them out? Is it only the activities visible to the user that I need to add?
Upvotes: 0
Views: 476
Reputation: 149
1- I would include it to the manifest anyways. I don't think it will hurt.
2- I have a question to anyone that wish to answer. Can I have something like this?
<activity android:name="com.hourglass.applications.CreateAlarm">
<intent-filter>
<action android:name="com.hourglass.applications.CreateAlarm" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I don't know if I can have the activity and action with the same name.
Upvotes: 0
Reputation: 4095
It would really help to see your code.
As someone else mentioned, it's fine to omit activities from your manifest that are never started directly (and there are instances where this makes sense), but this can also be bad practise. Are these helper classes? Are they extending Activity at all?
Upvotes: 0
Reputation: 2473
There's nothing wrong with having some activities that are not defined in the AndroidManifest file, as long as you do not attempt to start them.
So, the answer would be no, you do't have to add the activities that are there just for the sake of some sort of abstraction.
On the other hand, why would you want some classes with the application lifecycle functionality (and other Activity stuff) in place? It seems like a bad design and I'd really advise you to review the code.
Upvotes: 1
Reputation: 13327
you can't open i.e (display) an activity(or a sub type of it) into you application if it does not have <activity>
element in the manifest file
if you try to start an activity like this
Intent i = new Intent(this, Any_Activity.class);
startActivity(i);
you will get an error The application has stopped unexpectedly Please try agin
since no <activity>
tag for "Any_Activity" class is defined in the manifest.xml file
Upvotes: 0
Reputation: 29121
Declares an activity (an Activity subclass) that implements part of the application's visual user interface. All activities must be represented by elements in the manifest file. Any that are not declared there will not be seen by the system and will never be run.
This is the activity tag description on android developers page. hope this helps
Upvotes: 0