0

i have this code to check if bluetooth state is on or off:

        if (action.equals(mBluetoothAdapter.ACTION_STATE_CHANGED)) {
            final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, mBluetoothAdapter.ERROR);

            switch (state) {
                case BluetoothAdapter.STATE_OFF:
                    bluetooth.setText("Bluetooth Disabled");
                    break;
                case BluetoothAdapter.STATE_TURNING_OFF:
                    break;
                case BluetoothAdapter.STATE_ON:
                    bluetooth.setText("");
                    break;
                case BluetoothAdapter.STATE_TURNING_ON:
                    break;
            }
        }

How can i put this on the OnCreate so that when i start the app immediately without bt, the text "bluetooth is disabled" is shown. Because atm, it only triggers if I turn it on and turn it off again only.

Tom Smith
  • 1
  • 2

0 Answers0