title: Handle back button Android React Native
body: <p>I have created a React Native App. </p>
  
  <p>I am using BackHandler.  <a href="https://facebook.github.io/react-native/docs/backhandler.html" rel="nofollow noreferrer">https://facebook.github.io/react-native/docs/backhandler.html</a></p>
  
  <p>I am facing one weird issue, when I am running my app using </p>
  
  <pre><code>react-native run-android
  </code></pre>
  
  <p>my back button is working as expected. </p>
  
  <p>But when I am running using Android Studio, whenever I am clicking on back button on any screen, it is directly exiting the App. </p>
  
  <p>I have checked, the bundle js file is generating properly.</p>
  
  <p>Below is the code:</p>
  
  <pre><code> import {BackHandler} from 'react-native';
  
      class  App extends Component {
  
      constructor(props) {
          super(props)
          this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
  
      }
      componentWillMount(){
                BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
            }
  
       componentWillUnmount(){
              BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
          }
  
      handleBackButtonClick(){
              this.props.navigation.goBack(null);
              return true;
          }
      }
  </code></pre>
  
  <p><strong>EDIT: The issue is when the debugger is open, the back button is working, If not open, back button not working.</strong> </p>