Good day. In the application there are two fragments that dynamically replace each other.
In the activity to which they are attached there are two edittexta.
One of the fragments is placed in the backstack and it also appears when you click on the button in the activity. And depending on what data is currently in edittext activity, it performs its functions.
How to correctly implement a request to edittext, which is in activity, from a fragment when it appears? Now I have done this as follows, but I am not sure that it is correct.

public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); CustomEditText etFrom = (CustomEditText)getActivity().findViewById(R.id.searchFrom); CustomEditText etTo = (CustomEditText)getActivity().findViewById(R.id.searchTo); String From = etFrom.getText().toString(); String To = etTo.getText().toString(); if (From.equals("") || To.equals("")){ pbLoad.setVisibility(View.GONE); tvInformFragment.setVisibility(View.VISIBLE); if (stationFrom.equals("")){ tvInformFragment.setText(INF_ENTER_FROM); } else { tvInformFragment.setText(INF_ENTER_TO); } } else { pbLoad.setVisibility(View.VISIBLE); tvInformFragment.setVisibility(View.GONE); loadData(); } } 

    0