Copyright © 2008, 2009, 2010, 2011, 2012 Lars Vogel
|Revision 0.2 - 2.3||20.04.2009 - 24.06.2012||Lars
|bug fixes and enhancements|
Table of Contents
A fragment is always defined for another plug-in (host plug-in). At runtime the fragment is merged with its host project and for the runtime both projects are just one. Fragments are always optional for their host plug-in.
The Eclipse IDE supports the creation of fragments via fragment projects.
To create a fragment project select→ → → → .
Fragments are for example used for containing test classes. This way the tests can access the host plug-in classes, even if the host plug-in does not define them as external API. Sometimes tests are also contained in normal plug-ins, in this case they can only test the external API for other plug-ins.
Another typical usage example for fragments are translations and native code. A new translation can be contributed to a plug-in via a fragment.
Also plug-ins uses fragments to factor out their native code parts. Via a platform filter it can be defined that a fragment can only be activate on a certain platform. The Eclipse user interface library SWT uses this approach. More information on the platform filter can be found in the Eclipse help system if you search for the "OSGi Bundle Manifest Headers" term.
Last but not least fragments can be used to contain resources like icon sets or other images. This allows you to customize your application icons via the provided fragment.
If you find errors in this tutorial, please notify me (see the top of the page). Please note that due to the high volume of feedback I receive, I cannot answer questions to your implementation. Ensure you have read the vogella FAQ as I don't respond to questions already answered there.
vogella Training Android and Eclipse Training from the vogella team
Android Tutorial Introduction to Android Programming
Eclipse RCP Tutorial Create native applications in Java
JUnit Tutorial Test your application
Git Tutorial Put all your files in a distributed version control system