Sprawdź, czy bluetooth jest włączony za pomocą aplikacji na Androida

Chcę sprawdzić, czy bluetooth jest włączony w urządzeniu korzystającym z aplikacji na Androida. Użyłem metody .isEnabled. Ale jest błąd. Odkryłem (komentując linie), że błąd występuje w metodzie .isEnabled. Czy możesz mi pomóc?

final BluetoothAdapter bluetooth = BluetoothAdapter.getDefaultAdapter();

submitButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        String status = "Bluetooth";

        if(bluetooth != null) {
            if (bluetooth.isEnabled()) {
                String mydeviceaddress = bluetooth.getAddress();
                String mydevicename = bluetooth.getName();
                status = ("Address "+ mydeviceaddress + " Name" + mydevicename);
                Toast.makeText(getApplicationContext(), "" + status + "", Toast.LENGTH_LONG).show();
            } else {
                status = ("Bluetooth not enabled");
                Toast.makeText(getApplicationContext(), "" + status + "", Toast.LENGTH_LONG).show();
            }
        } else {
            Toast.makeText(getApplicationContext(), "" + status + "", Toast.LENGTH_LONG).show();
        }
    }
}

questionAnswers(4)

yourAnswerToTheQuestion