У меня есть нижнее меню и я хочу чтобы оно исчезало когда открылась регистрация , помни что я заменяю фрагменты расположение на MainActivity : package com.example.myapp_2.UI.view.activities;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.myapp_2.Data.model.database.Room.SQLITE.Note;
import com.example.myapp_2.ViewModel.ViewModels.NoteViewModel;
import com.example.myapp_2.R;
import com.example.myapp_2.UI.view.fragments.FirstFragment;
import com.example.myapp_2.UI.view.fragments.SecondFragment;
import com.example.myapp_2.UI.view.fragments.ThirdFragment;
import com.example.myapp_2.databinding.ActivityMainBinding;

import java.util.List;


public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private NoteViewModel noteViewModel;

    private BroadcastReceiver broadcastReceiver;


    Button button1;
    Button button3;
    // private FirstFragment firstFragment = new FirstFragment();
    ActivityMainBinding binding;
    private Button btn_fragment1,btn_fragment2,btn_fragment3;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        replaceFragment(new FirstFragment());

        binding.bottomNavigationView.setOnItemSelectedListener(item -> {
            switch(item.getItemId()){
                case R.id.home:
                    replaceFragment(new FirstFragment());
                    break;
                case R.id.profile:
                    replaceFragment(new SecondFragment());
                    break;
                case R.id.settings:
                    replaceFragment(new ThirdFragment());
                    break;
            }
            return true;
        });

        getSupportFragmentManager().beginTransaction().replace(R.id.nav_container, new FirstFragment()).addToBackStack(null).commit();

        if (findViewById(R.id.bt3) != null) {
            binding.bottomNavigationView.setVisibility(View.GONE);
        } else {
            binding.bottomNavigationView.setVisibility(View.VISIBLE);
        }
    }

    private void registerBroadcastReceiver() {
        broadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
            // Получение сообщения
                String action = intent.getAction();
                if(action.equals("com.example.myapplication_2.SEND_MESSAGE")) {
                    String message = intent.getStringExtra("MESSAGE");
            // Вывод сообщения в лог
                    Log.d("MyApp2", "Received message: " + message);
                }
            }
        };
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("com.example.myapplication_2.SEND_MESSAGE");
        registerReceiver(broadcastReceiver, intentFilter);
    }


    @Override
    public void onClick(View view) {//2 способ

    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
// Удаление приемника
        unregisterReceiver(broadcastReceiver);
    }

    private void replaceFragment(Fragment fragment){
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.nav_container,fragment);
        String A = "HELLO";


        Bundle bundle = new Bundle();
        bundle.putInt("hello world", 4344);
        fragment.setArguments(bundle);


        fragmentTransaction.commit();

    }

}