Sunday, April 8, 2012

Re: [android-developers] Global variable extend application class

The HashMap is valid when i put it in the Intent, and when I get it back it is also valid.

UPDATE:

So I fixed this issue.  In my onActivityResult, I was iterating through the HashMap like so:

Iterator<Entry<String, Boolean>> it = sc.entrySet().iterator();
while (it.hasNext()) {
HashMap.Entry pairs = (HashMap.Entry) it.next();
String contactId = pairs.getKey().toString();
boolean selected = (Boolean) pairs.getValue();
if (selected) {
selectedContactsText += getName(contactId) + ", ";
Log.d("Messenger", getName(contactId) + " was selected");
Log.d("Messenger", selectedContactsText + " is the text");
}
it.remove(); // avoids a ConcurrentModificationException
}

However i noticed the last statement of the while loop was in fact removing elements from the HashMap.  
So I commented this line out and all works as intended.

On Sunday, April 8, 2012 3:28:12 PM UTC-7, TreKing wrote:
Have you stepped through the code? Is the HahMap valid when you put it in the Intent? When you get it back, is it valid then?

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices

--
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