Right now, I know how to send an ArrayList
of Strings
through intent
by doing this to send:
Intent intent = new Intent(MainActivity.this, MapActivity.class);
intent.putStringArrayListExtra("list", list);
startActivity(intent);
and this to receive:
Intent i = getIntent();
ArrayList<String> list = i.getStringArrayListExtra("list");
But I want to send an ArrayList of LatLngs, like this:
Intent intent = new Intent(MainActivity.this, MapActivity.class);
intent.putLatLngArrayListExtra("listLatLng", listLatLng);
startActivity(intent);
\\pseudo code, obviously
and then:
Intent i = getIntent();
ArrayList<String> list = i.getLatLngArrayListExtra("listLatLng");
\\pseudo code, obviously
Any ideas on how to do this? Is there any easy way or do I have to modify something? Thanks.
I would use android.location; It extends Parcelable and you can easily create and store the Locations in an arrayList created from lat and lon values
Intent i = new Intent(MainActivity.this, MapActivity.class);
i.putParcelableArrayListExtra(name, value);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.