1

I have collected different latitude and longitude of locations. I want to know if i can set them as string of array for e.g(String lat = {"9385853.0094", "23123123.234")and then pass them via intent so that i can display the location in google map using lat/long in new activity.

Mesh
  • 19
  • 1
  • 8
  • 1
    See http://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android for information on passing data between activities. When the google map activity loads, read in the passed data and set the coordinates. Also, can you show us the code you have for creating the new activity or intent? – WOUNDEDStevenJones Feb 17 '15 at 22:31

1 Answers1

5

For example you have two classes called Maps.java and Routes.java.

Use the following code to pass the LatLng

LatLng fromPosition = new LatLng(9385853.0094, 23123123.234 );
LatLng toPosition = new LatLng(11.145315551, 99.333455333);

Bundle args = new Bundle();
args.putParcelable("from_position", fromPosition);
args.putParcelable("to_position", toPosition);

i.putExtra("bundle", args);

Intent i= new Intent(Maps.this, Routes.class);
        startActivity(i);

And at the receiving end use the following code

Bundle bundle = getIntent().getParcelableExtra("bundle");
LatLng fromPosition = bundle.getParcelable("from_position");
LatLng toPosition = bundle.getParcelable("to_position");

Hope this Helps!

AniV
  • 3,997
  • 1
  • 12
  • 17