title: Application Exited when i turn on Bluetooth programatically in a Button click in android
body: <p>In my application in a button click i want to programatically enable Bluetooth for this i am using below code and i am able to enable the Bluetooth but after pressing Yes in the Bluetooth enable dialog i am exiting application,i don't want to exit the application i want to show the same screen after enabling the Bluetooth also how can i do this please check the below code i am using for enabling Bluetooth and also onActivityResult code method.<code>enter code here</code></p>
  
  <pre><code>    if(v.getId() == R.id.Button)
  {
      BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
      final ArrayAdapter mArrayAdapter = null;
      if (mBluetoothAdapter == null) {
          // Device does not support Bluetooth
      }
      if (!mBluetoothAdapter.isEnabled()) {
          Intent enableBtIntent = new    Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
          startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
          }
  
  }
  
      protected void onActivityResult(int requestCode, int resultCode, Intent data)
      {
      switch(requestCode) {
      case REQUEST_ENABLE_BT:
      if (resultCode == RESULT_OK) {
        String name = data.getStringExtra("Bluetooth Enabled");
        Toast.makeText(this, "You have chosen the book: " + " " + name,   Toast.LENGTH_LONG).show();
        break;
    }
     }
    }   
  </code></pre>