But if that is not possible for your design or the intents needs to pass 
Parcelables that you have created, use this construct:

Say you need to pass a Parcelable inside an extra of an Intent from an 
Activity to a remote Service. As soon as the remote Service touches the 
extras  (i.e. the Bundle) of the Intent you may get a 
ClassNotFoundException. Before touching the Bundle do this:

// remotePackageName is the packageName in which your Activity runs.
Context remoteContext = this.createPackageContext(remotePackageName, 
Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);

Then call intent.setExtrasClassLoader(remoteContext.getClassLoader())before you 
do any call to 
intent.getXXXExtra(...).
Or call bundle.setClassLoader(remoteContext.getClassLoader()) before you do 
any call to bundle.getXXX(...).

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to