I’m using LocalBroadcastManager to send data between classes. I’m trying to send an ArrayList of String objects, 1 dimensional, in one of them. The array has all my strings when I send it, but on the receiving end it is empty. Has anyone seen this before? Here’s my code.
Send Message:
Intent updatedIdsIntent = new Intent(Common.ContentIdsUpdatedNotification);
updatedIdsIntent.putStringArrayListExtra(Common.UpdatedContentIdsKey, this.updatedContentIds);
LocalBroadcastManager.getInstance(ctx).sendBroadcast(updatedIdsIntent);
Retrieve Message (always empty):
Log.i(TAG, "content ids updated in activity " + intent.getStringArrayListExtra(Common.UpdatedContentIdsKey));
As it turns out, I’m emptying that array after I send it off. For
some reason the broadcast receiver is either using a reference to it,
so it gets the cleared one, or is sending after it’s cleared. Either
way, not clearing the array after allows it to show up correctly.
Fixed it by copying the array into a new array and sending that.