android - Passing TreeMap between Activities Using Intent/Bundle -


i'm trying pass treemap between 1 activity , another. treemap of type treemap>

i tried making trip serializable , parcelable can't work. add map bundle during onsaveinstancestate , resume during onrestoreinstancestate not between activities.

here definition of trip

package stations;  import java.io.ioexception; import java.io.serializable;  import android.text.format.time;  public class trip implements serializable {      private static final long serialversionuid = 1l;     time m_time = new time();     public trip()     {         m_time.settonow();     }      private void writeobject(java.io.objectoutputstream out)             throws ioexception {         out.writelong(m_time.tomillis(false));     }      private void readobject(java.io.objectinputstream in)             throws ioexception, classnotfoundexception {         m_time = new time();     m_time.set(in.readlong());     } } 

this part works well:

    @override     public void onsaveinstancestate(bundle savedinstancestate) {     savedinstancestate.putserializable(personal_set_str, m_personalset);     super.onsaveinstancestate(savedinstancestate);     }      @suppresswarnings("unchecked")     public void onrestoreinstancestate(bundle savedinstancestate) {         super.onrestoreinstancestate(savedinstancestate);         m_personalset = (treemap<integer,vector<trip>>)savedinstancestate.getserializable(personal_set_str);     toast.maketext(this, "on restore " + m_personalset.size(), toast.length_short).show();     }    

here how start second activity

intent intent = new intent(this, secondactivity.class); bundle b = new bundle(); b.putserializable(personal_set_str, m_personalset); intent.putextras(b); startactivity(intent);  

here oncreate of secondactivity

@suppresswarnings("unchecked") @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);          bundle b = getintent().getextras();     //this next line throws exception     m_personalset = (treemap<integer,vector<trip>>)b.getserializable(firstactivity.personal_set_str); } 

the log cat: 05-21 16:34:24.086: e/androidruntime(17343): java.lang.runtimeexception: unable start activity componentinfo{com.me.atme/analysis.secondclass}: java.lang.classcastexception: java.util.hashmap cannot cast java.util.treemap

any ideas why it's comming out of bundle hashmap , not treemap? , why between 2 activities?

thanks


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -