Friday, March 2, 2012

[android-developers] Re: Passing ArrayList in BroadcastReceiver in Android

What's confusing to me is that it actually gets an ArrayList<String>.
It's just been emptied out somehow.


On Mar 2, 1:25 pm, tatebn <brandonnt...@gmail.com> wrote:
> Accidentally left that prefix in the code there.  That's not the issue
> in the actual app.
>
> On Mar 2, 1:17 pm, tatebn <brandonnt...@gmail.com> wrote:
>
>
>
>
>
>
>
> > It's the intent in the broadcast receiver's onReceive message
>
> > /** Handler for content ids updated. */
> > private BroadcastReceiver mContentIdsUpdated = new BroadcastReceiver()
> > {
> >      @Override
> >      public void onReceive(Context context, Intent intent) {
> >          Log.i(TAG, "received " +
> > intent.getStringArrayListExtra(Common.CDCUpdatedContentIdsKey).size()
> > + " items in receiver"); // 0
> >          Log.i(TAG, "content ids updated in activity " +
> > intent.getStringArrayListExtra(Common.CDCUpdatedContentIdsKey));  //
> > empty array
> >      }
>
> > };
>
> > // In oncreate
>
> > LocalBroadcastManager.getInstance(this).registerReceiver(mContentIdsUpdated ,
> >                             new IntentFilter(Common.ContentIdsUpdatedNotification));
>
> > On Mar 2, 12:15 pm, Mark Murphy <mmur...@commonsware.com> wrote:
>
> > > Are you sure you are looking at the right Intent?
>
> > > On Fri, Mar 2, 2012 at 11:25 AM, tatebn <brandonnt...@gmail.com> wrote:
>
> > > > 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 (I can print the array here and it has 5 items):
>
> > > > 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));
>
> > > > Why are the items gone from the array in the broadcast receiver?
>
> > > > --
> > > > 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+unsubscribe@googlegroups.com
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-developers?hl=en
>
> > > --
> > > Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > > Warescription: Three Android Books, Plus Updates, One Low Price!

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate