-1

Maps and Fragments

This is my design Image

enter image description here

I have two fragments.FirstFragment -> map and SecondFragment -> weather

I am getting Latitude and Longitude from First Fragment from the code below:

mPlace.setLatlng(place.getLatLng());

In the SecondFragment i am executing Latitude and Longitude on this code:

asyncTask.execute("10.873873","78.818729");

Problem: I wanted to pass Latitude and Longitude from my FirstFragment to SecondFragment.

And i tried Bundle with arguments to pass data.it does'nt work.

Omkar
  • 3,040
  • 1
  • 22
  • 42
shyam
  • 1,084
  • 12
  • 20

1 Answers1

0

If your Activity will only have a single copy of each Fragment, then you can simply have the Activity hold the LatLng variable, and it will be accessable from both Fragments.

lionscribe
  • 3,413
  • 1
  • 16
  • 21
  • Thank u @lion.If i select a particular location in map(fragment1).i must get the weather of that location in my fragment2.Tried interfaces and bundle they does'nt work.Is any other way?? what are the steps??? – shyam Feb 27 '18 at 11:05
  • @shyam notify the Activity, and have activity notify the fragment2. – lionscribe Mar 05 '18 at 21:37
  • Thank u i will notify @lionscribe – shyam Mar 06 '18 at 05:40