How to send a LatLng instance to new intent

use the putParcelable method to attached LatLng Object to a Bundle:

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

Now attach it to your intent:

i.putExtra("bundle", args);

To get it in your new activity:

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

Much easier way, since LatLng is parcelable:

on caller side:

LatLng position = new LatLng(16.099108, -22.812924); // Boa Vista
intent.putExtra("Pos", position);

On receiver side

LatLng position = getIntent().getExtras().getParcelable("Pos");

Tags:

Maps

Android