Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android abstract activity in manifest

For my application I am going to create a variety of abstract classes that extend the android.app.Activity and android.app.Service classes.

  • When I subclass my abstract classes how do I add them to the android manifest?
  • Do I need to add both the abstract class and my sub class to the manifest or just the subclass?
  • Do they need to be in the same package?
like image 663
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz Avatar asked Apr 30 '11 20:04

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz


3 Answers

You add the final subclasses to the manifest as regular Activities/Services; the abstract classes don't need to be there, as the manifest is only a lookup so the system knows which class to launch in response to an Intent

If by 'package' you mean Java package (e.g. com.mycompany.whatever), then no, just add the relevant import (or use the fully qualified name) when creating the subclass.

If by 'package' you mean APK, then yes, the abstract base should be in there with the regular code, as although it is possible to call between APKs, you this relies on classes you can instantiate. You can split the abstract classes out into an Android library project, if they're going to get re-used - Android library projects are essentially shared source, rather than traditional Java jars.

Let me know if you need more details on any of this, as this is quite a broad question, and I'd like to keep the answer size managable

like image 151
Phil Lello Avatar answered Oct 10 '22 08:10

Phil Lello


You only need to include Activity classes that you are going to instantiate with an Intent. If your abstract class only exists to subclass other Activities, you shouldn't need to include it in the Manifest.

like image 27
LeffelMania Avatar answered Oct 10 '22 07:10

LeffelMania


You will add the subclasses to the manifest just like any other Activity/Service/BroadcastReciever. You do not have to add the abstract classes to the mainifest. Subclasses do not have to be in the same package as their parent if you import the parent's package.

like image 25
mtmurdock Avatar answered Oct 10 '22 08:10

mtmurdock