I created back arrow button via code:
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        View rootView = inflater.inflate(R.layout.w_output_power, container, false);
        calculatePower(rootView);
        return rootView;
    }
And I cannot implement functionality to go back to previous fragment when back arrow is pressed. I've seen that it should be done with method handleOnBackPressed() but I am not sure how exactly. Thanks for help in advance.
 
     
    