I Am trying to send a Parcelable
object from an Activity
to a IntentSerivce
. The code below was working well, I have made changes to the project but not that section, and have no idea why this has stopped working.
Activity:
Bundle bundle = new Bundle();
bundle.putParcelable("client", client);
bundle.putParcelable("job", job);
Intent intent = new Intent(this, EmailService.class);
intent.putExtra("bundle", bundle);
intent.putExtra("type", "type1");
startService(intent);
Service:
protected void onHandleIntent(Intent intent) {
String type = intent.getStringExtra("type");
Bundle bundle = intent.getBundleExtra("bundle");
Client client = bundle.getParcelable("client");
...
The line Client client = bundle.getParcelable("client");
causes java.lang.NullPointerException: Attempt to get length of null array
. The Client
object is not null in the Activity
and the bundle
is not null in the Service
. I am also able to pass my Client
object around between activities without any problems.
Why has this stopped working / How do I fix this?