title: Back press or finish() does not work in closing the activity
body: <p>I have an Android app that constantly receives data over Bluetooth and pushes data from <code>MainActivity</code> to <code>MainActivity2</code> through <code>Intent</code>. The <code>MainActivity</code> has an <code>ImageButton</code> that allows switching to the <code>MainActivity2</code>.</p>
  
  <p>I am using a variable <code>Clicked</code> which is <code>true</code> when the <code>ImageButton</code> is clicked and <code>false</code> when <code>onBackpressed()</code>. I use the the <code>true/false</code> condition to start the Bluetooth receiving when I click on an <code>ImageButton</code>. I am able to receive the Bluetooth data in <code>MainActivity2</code>, but <code>onBackpressed</code> closes the <code>MainActivity2</code> returning to <code>MainActivity</code>. Then, as soon as a new data arrives, it automatically starts <code>MainActivity2</code> again.
  I want that <code>MainActivity2</code> gets the data only when I click <code>ImageButton</code> and <code>onBackPressed</code>, <code>MainActivity2</code> is permanently closed, but it does not happen.</p>
  
  <p><strong>MainActivity - ImgButtonFunction</strong></p>
  
  <pre><code>public void onImgButtClick(View view){
      Intent getNameScreenIntent = new Intent(MainActivity.this, MainActivity2.class);
      final int result=1;
      Clicked=true;
  
      startActivityForResult(getNameScreenIntent,result);
  }
  </code></pre>
  
  <p><strong>MainActivity - small part of data receive handler</strong></p>
  
  <pre><code>if (action.equals(UartService.ACTION_DATA_AVAILABLE)) {
  
      final byte[] txValue = intent.getByteArrayExtra(UartService.EXTRA_DATA);
      runOnUiThread(new Runnable() {
          public void run() {
              try {
                  String text = new String(txValue, "UTF-8");
                  /*Character[] Chararray = new Character[text.length()];
  
                  for (int i = 0; i &lt; text.length(); i++) {
                      Chararray[i] = new Character(text.charAt(i));
                  }*/
  
                  /*  Character[] Chararray = new Character[text.length()];
                      byte txByte=0;
                      for (int i = 0; i &lt; txValue.length(); i++) {
                      Chararray[i] = new Character(text.charAt(i));}
                  */
  
                  String currentDateTimeString = DateFormat.getTimeInstance().format(new Date());
  
                  /*for (String retval: text.split("\n")) {
                      Chararray[i]=retval;
                      listAdapter.add("[" + currentDateTimeString + "] RecvX: " + retval + "km/h");
                  }*/            
  
                  String  str1 = String.valueOf(txValue[0]);
                  listAdapter.add("[" + currentDateTimeString + "] RecvX: " +str1 + "km/h");
                  messageListView.smoothScrollToPosition(listAdapter.getCount() - 1);
                  if (Clicked==true) {
                      Intent ii = new Intent(MainActivity.this, MainActivity2.class);
                      ii.putExtra("RxString", str1);
                      startActivity(ii);
                  }
              } catch (Exception e) {
                    Log.e(TAG, e.toString());
              }
          }
      });
  }
  </code></pre>
  
  <p><strong>MainActivity2 - onBackPressed handler</strong></p>
  
  <pre><code>@Override
  public void onBackPressed() {
      Intent i=new Intent(this, MainActivity.class);
      i.putExtra("Clicked",false);
      i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| Intent.FLAG_ACTIVITY_SINGLE_TOP);
      startActivity(i);
      finish();
  }
  </code></pre>