I'm still a bit confused on what you're doing, but I would suggest:

1 - Subclass ItemizedOverlay instead of Overlay to manage a collection of
similar items at once. It maintains a list OverlayItems that represent each
unique point on the map. In your case these would be the Track points you
have.

2 - In your subclass, implement Parcelable and the write method and
constructor that are required to read from / write to a Parcel. In this case
you would write out  / read back each of your OverlayItem's location.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Tue, Jan 5, 2010 at 5:47 PM, Stefan <ebay-dah...@web.de> wrote:

> hi,
> thanks for your answer :)
>
> On Jan 5, 11:30 pm, TreKing <treking...@gmail.com> wrote:
> > OK, well your main problem is that while you implemented the Parcelable
> > class, you didn't implement the writeToParcel method or the constructor
> that
> > takes a Parcel. That's the key.
> >
>
> in one other class of my app i has implement the parcelable to, but
> there i mustnt implement these methods. i dont know why but it works.
> this other class is my "SaveHelper" class (its like a singleton - i
> only have one object), where i save my track/route... and i test it: i
> walk around my block and i rotate the handy several times
> (==>recreation of my activity..). and after saving my gpx file i see,
> that ALL points are saved.
>
> > You need to implement the first method to save all you state information
> > (i.e., your member variables) to the Parcel object.
> > Then implement the constructor to restore your instance state from the
> > incoming Parcel object.
>
> I override my Overlay object, how you can see in my code and because
> of that i would only get the last overlay back?!?!
> I think you mean, that i do following:
>
>  @Override
>  public void writeToParcel(Parcel dest, int flags) {
>            // TODO Auto-generated method stub
>              dest.writeInt( (int)gp1.getLatitude()); //something like
> that
> }
>
> and
>
> private TrackOverlay(Parcel in) {
>         gp1.setLatitude(in.readInt());
>     }
>
> but the onSaveInstanceState will only be called, if i pause the
> activity?! So i can only save the last to (TrackOverlay) object?!?!
> Or if i implement these methods i save all my Overlays?!?
>
> >
> > Then in your MapActivity onSavedInstanceState, iterate through all of
> your
> > Overlays and shove them into an array you can store in the Bundle.
> > In onRestoreInstanceState, get a list of Parcelables from the Bundle and
> > re-create all of your Overlays (using the constructor that takes a
> Parcel).
>
> Perhaps it is easier to save all GeoPoints in a list and in
> onSaveInstanceState() i iterate through that list and save all
> GeoPoints in a "int [] lat" and "int [] lon" array and put it to my
> bundle and in onRestoreInstanceState i read this arrays and iterate
> through these arrays  and draw the Overlays again, like:
>
> gp1.setLatitude(lat[0]); .....
> for(int i= 1; i< lat.length; i++)
> {
>    gp2 = gp1;
>    gp1.setLatitude(..)
> ...
>   newOverlay = new TrackOverlay(gp1, gp2, MODUS);
>   map.getOverlays().add(newOverlay);
> }
> map.ivalidate();
>
>
>
> But what is more efficient and/or more elegant ?
>
> >
> > Other bit of advise: get rid of that "if (first) { /*initialze*/}" code.
> Set
> > up your MyLocationOverlay object in onCreate. If you need to have a
> starting
> > location while you wait for the first update, use getLastKnownLocation().
> >
>
> Yes, this is not the best solution and i will optimize it soon :)
>
> > I hope that makes sense and helps some.
>
> Thanks for your detailed answer.
>
> Stefan
>
> --
> 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+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to