在Android </string>中的BroadcastReceiver中传递ArrayList <string>

时间:2012-03-01 21:28:12

标签: android android-intent

我正在使用LocalBroadcastManager在类之间发送数据。我正在尝试在其中一个中发送1个String对象的ArrayList。当我发送它时,数组包含我的所有字符串,但在接收端它是空的。谁看过这个吗?这是我的代码。

发送消息:

Intent updatedIdsIntent = new Intent(Common.ContentIdsUpdatedNotification);
    updatedIdsIntent.putStringArrayListExtra(Common.UpdatedContentIdsKey, this.updatedContentIds);

LocalBroadcastManager.getInstance(ctx).sendBroadcast(updatedIdsIntent);

检索消息(始终为空):

Log.i(TAG, "content ids updated in activity " + intent.getStringArrayListExtra(Common.UpdatedContentIdsKey));

1 个答案:

答案 0 :(得分:0)

事实证明,我把它发送出去之后就把它清空了。对于 广播接收器要么使用它的参考, 所以它被清除了,或者在它被清除后发送。或 方式,不允许它正确显示后清除数组。

通过将数组复制到新数组并发送它来修复它。