0

I'm working on a map project and I need to return value from DialogFragment to a SupportMapFragment.

@Override
public void onMapLongClick(LatLng point) {

    mMap.addMarker(new MarkerOptions().position(point).title(point.toString()));
    markerClicked = false;
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    DataImportDialog pdf = DataImportDialog.newInstance("Enter Something");
    Bundle args = new Bundle();
    args.putDouble("Lat", point.latitude);
    args.putDouble("Lng", point.longitude);
    pdf.setArguments(args);
    pdf.show(ft, "PROMPT_DIALOG_TAG");

}
Amin Mohammadi
  • 183
  • 2
  • 17

1 Answers1

0

You can use interface to communicate between two fragments or activity. here is good example in Android doc

Or there is way using setTargetFragment(Fragment fragment,int requestCode) so that you can get fragment instance in your replaced or added fragment and you can call onActivityResult with bundle.. more about this on developer doc

here is complete example of same https://stackoverflow.com/a/13733914/942224

Community
  • 1
  • 1
Sanket Kachhela
  • 10,861
  • 8
  • 50
  • 75