title: Multiple request codes in an onActivityResult
body: <p>I have two seperate <code>startActivityForResult</code>s which utilize different activities. I want to be able to handle the results of these activity all in my main activity. </p>
  
  <p>However, when returning to the main activity, the function is performed (e.g. in the case of requestCodeText the text on btn3 is set to the right value) but then the app freezes.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    final int request_CodeNumber = 1;
  final int request_CodeText = 2;
  
      public void onActivityResult(int requestCode, int resultCode, Intent data)
  {
      super.onActivityResult(requestCode, resultCode, data);
  
      switch(requestCode) {
      case request_CodeText:
          Uri uri = data.getData();
          final Button btn3 = (Button)findViewById(R.id.btnMessage);
          if(resultCode == RESULT_OK) {
              btn3.setText((String) uri.toString());
          }
          break;
  
      case request_CodeNumber:
          Uri uri2 = data.getData();
          Cursor c = null;
          try {
              c = getContentResolver().query(uri2, new String[]{
                      ContactsContract.CommonDataKinds.Phone.NUMBER,
                      ContactsContract.CommonDataKinds.Phone.TYPE,
                      ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME},
                      null, null, null);
              if (c!= null &amp;&amp; c.moveToFirst()) {
                  String number = c.getString(0);
                  int type = c.getInt(1);
                  String contactName = c.getString(2);
                  showSelectedNumber(type, number, contactName);
              }
          } finally {
              if (c != null) {
                  c.close();
              }
          }
      break;
      }
  }
  </code></pre>
  
  <p>I get the following in the logcat:</p>
  
  <pre><code>11-20 21:52:45.155: D/dalvikvm(655): GC_FOR_ALLOC freed 66K, 4% free 8004K/8259K, paused 85ms, total 97ms
  11-20 21:52:45.215: I/dalvikvm-heap(655): Grow heap (frag case) to 10.633MB for 2903056-byte allocation
  11-20 21:52:45.485: D/dalvikvm(655): GC_CONCURRENT freed &lt;1K, 3% free 10838K/11143K, paused 122ms+20ms, total 273ms
  11-20 21:52:47.055: D/libEGL(655): loaded /system/lib/egl/libEGL_emulation.so
  11-20 21:52:47.076: D/(655): HostConnection::get() New Host Connection established 0x2a0d7d68, tid 655
  11-20 21:52:47.218: D/libEGL(655): loaded /system/lib/egl/libGLESv1_CM_emulation.so
  11-20 21:52:47.236: D/libEGL(655): loaded /system/lib/egl/libGLESv2_emulation.so
  11-20 21:52:47.425: W/EGL_emulation(655): eglSurfaceAttrib not implemented
  11-20 21:52:47.476: D/OpenGLRenderer(655): Enabling debug mode 0
  11-20 21:52:54.076: W/EGL_emulation(655): eglSurfaceAttrib not implemented
  11-20 21:52:59.646: W/EGL_emulation(655): eglSurfaceAttrib not implemented
  </code></pre>