tags:

views:

22

answers:

1

I have a service that produces as result a SortedSet object. I need to pass it to another Intent that will use it. First is put in the notification area, then when the user actions it it will need to fire the activity.

As it it's own SortedSet is not Parcelable nor Serializable so it won't work. One single item in SortedSet is already parcelable and it's used fine, but I need the whole set.

How to pass a SortedSet as an Intent's extra?

+1  A: 

I found out:

intent.putExtra("results", result.toArray());//passes as serializable and as Array

then read out by reconstructing the array into the SortedSet

In my case it was:

Serializable s = this.getIntent().getSerializableExtra("results");
Object[] o = (Object[]) s;
if (o != null) {
    resultSet = new TreeSet<RatedMessage>(new Comp());
    for (int i = 0; i < o.length; i++) {
        if (o[i] instanceof RatedMessage) {
            resultSet.add((RatedMessage) o[i]);
        }
    }
}

now I can use resultSet further.

Pentium10