Bluetooth isEnabled() fails

To check Bluetooth state, ON programmatically: 1. Add Following Permission : -

android.permission.BLUETOOTH
2. Use Following Function For Enable BLUETOOTH:-
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

private void turnOn() {

   if (!mBluetoothAdapter.isEnabled()) {
        Intent enableBtIntent = new 
        Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivity(enableBtIntent);
    }

}