Created: 2012-03-26 02:21
Updated: 2016-09-15 11:24
License: apache-2.0


CWAC ParcelHelper: Runtime Assistance for Parcel Developers

If you are creating reusable libraries using the techniques described in the Android Parcel Project, then this library may be useful to you.

It supplies you with a ParcelHelper class, designed to help you deal with the naming conventions required of resources packaged in a reusable library.

This is packaged as an Android library project, though a simple JAR is also available from the Downloads section of this GitHub repository.


Your library's code creates a ParcelHelper instance, supplying it with your library's name (e.g., my-parcel) and a Context suitable for looking up resource IDs. Then, when you need a resource ID, you call one of the ParcelHelper getter methods:

  • getLayoutId() for layouts (replacing R.layout)
  • getItemId() for item IDs (replacing
  • getMenuId() for menus (replacing
  • getDrawableId() for drawables (replacing R.drawable)
  • getStyleableId() for so-called "styleables" (replacing R.styleable)
  • getStyleableArray() for getting the int[] array of "styleables"
  • getIdentifier() for anything else

Each of those takes the original name of the resource (e.g., "main") as a parameter. getIdentifier() takes the type of the resource as the second parameter (e.g., "string" for a string resource).

The advantage of using ParcelHelper is two-fold:

  1. It caches the lookups, since they are relatively expensive.
  2. It automatically mangles in your parcel name wherever it is needed.


None at present.


This is version v0.2.0 of this library.


There is no demo project. Please refer to the cwac-colormixer library for an example of ParcelHelper in use. This is also covered in the Android Parcel Project's developer documentation.


The code in this project is licensed under the Apache Software License 2.0, per the terms of the included LICENSE file.


If you have questions regarding the use of this code, please post a question on StackOverflow tagged with commonsware and android. Be sure to indicate what CWAC module you are having issues with, and be sure to include source code and stack traces if you are encountering crashes.

If you have encountered what is clearly a bug, please post an issue. Be certain to include complete steps for reproducing the issue.

Do not ask for help via Twitter.

Release Notes

v0.2.0: converted to Android library project

Who Made This?


Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more