title: Check current Bluetooth discoverability state
body: <p>So, I have been cracking my head how to check current Bluetooth discoverability state. I want to deal with simple problem which is:
  When user starts the Bluetooth discoverability on the device by clicking button, it pops up the log with a permission to enable to Bluetooth discoverability. When the user agrees, it is enabled and other button is set to be enabled. But when the user denies it, the next button is set enabled anyways and the previous becomes unavailable.</p>
  
  <p>What changes should I make in my code to enable start discovarability button enabled again when user denies the Bluetooth discoverability of the device?</p>
  
  <p>Is it possible to return the current state to some variable? If so, how?</p>
  
  <p>I tried to operate on some variables which depended on BTDiscoverable(); method but with no luck.</p>
  
  <p>I checked this Android SDK <a href="http://developer.android.com/guide/topics/connectivity/bluetooth.html" rel="nofollow">documentation</a> but it is only said about turning it on, not off nor checking the current state.</p>
  
  <pre><code>public void onClick(View v) {
      Button bttn = (Button) v;
  
      if(bttn.getId() == R.id.bt_server_start)
      {
          /*
           * If BluetoothAdapter name does not start with BT_ prefix, add it to the name, then proceed
           */
          if (!mBluetoothAdapter.getName().startsWith(PREFIX))
              mBluetoothAdapter.setName(PREFIX + mBluetoothAdapter.getName());
          /*
           * Check the connectability/discoverability, compare to the statemanet made by user that it is enabled.
           * If they are not equal, run BTDiscoverable method - set device to be discoverable by other devices
           */
          if(mBluetoothAdapter.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE)
              BTDiscoverable();
  
          /*
           * As the bluetooth is now on and the device can be connected/discovered, USER MUST START THE SERVER SITE ON DEVICE BY
           * CREATING NEW THREAD
           */
  
          DeviceServer = new AcceptThread();
  
          /*
           * Start the thread
           */
          DeviceServer.start();
  
          /*
           * Set the availability of the button
           */
  
          bttn.setEnabled(false);
          ((Button) this.findViewById(R.id.bt_server_stop)).setEnabled(true);
  
          } else if (bttn.getId() == R.id.bt_server_stop) 
          {
              DeviceServer.cancel();
              bttn.setEnabled(false);
              ((Button) this.findViewById(R.id.bt_server_start)).setEnabled(true);
              BTDeviceName();
          }
  }
  </code></pre>
  
  <p>EDIT: Well, usage of this this command again provides the outcome that I expected.</p>
  
  <pre><code>if(mBluetoothAdapter.getScanMode()==BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE)
  </code></pre>