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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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!