If you want to communicate between activity and fragments you must notice to this tip: To allow a Fragment to communicate up to its Activity, you can define an interface in the Fragment class and implement it within the Activity. The Fragment captures the interface implementation during its onAttach() lifecycle method and can then call the Interface methods in order to communicate with the Activity.
Please refer to Communicating Between Activity and Fragment
If you want to communicate in reverse you can do this code:
public class MainFragment extends Fragment {
public void callBack() {
// Do SomeThing
}
}
public class MainActivity extends Activity {
public void callFragmentCallBack() {
MainFragment fragment = (MainFragment) getFragmentManager().findFragmentById(R.id.fragment_main);
fragment.callBack(); // This line is important
}
}