0

I want to pass an ArrayList of LatLng variables from one Activity to another through button click.

The one available for String is not working Please help me out....

N J
  • 27,217
  • 13
  • 76
  • 96
  • possible duplicate of [How to send an object from one Android Activity to another using Intents?](http://stackoverflow.com/questions/2139134/how-to-send-an-object-from-one-android-activity-to-another-using-intents) – Pankaj Jun 19 '15 at 11:58

2 Answers2

0

Pass it as an ArrayList of Parcelable objects.

// Put the coordinates
ArrayList<LatLng> coordinates = new ArrayList<>();
Bundle bundle = new Bundle();
bundle.putParcelableArrayList("coordinates", coordinates);

// Get the coordinates
coordinates = bundle.getParcelableArrayList("coordinates");

To pass the bundle you need to the intent object you use to invoke the other activity:

Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
intent.putExtras(bundle);
startActivity(intent);

Then in the SecondActivity's onCreate you fetch the bundle:

ArrayList<LatLng> coordinates = getIntent().getParcelableArrayListExtra("coordinates");
Simas
  • 43,548
  • 10
  • 88
  • 116
0

I think you should parceble class or getParceble()

check following link:link 1

link 2

Community
  • 1
  • 1
Vishal Gadhiya
  • 450
  • 1
  • 6
  • 21