title: How to return result from onActivityresult
body: <p>I am trying to pick a contact from Default Contact app. I got information from a contact successfuly. Now i want to save this data in an arraylist, type of contact. how from onActivityResult? I am searching this for 5 hours.I am new in android. </p>
  
  <p>here is my onActivityResult's code</p>
  
  <pre><code>public void onActivityResult(int reqCode, int resultCode, Intent data) {
      super.onActivityResult(reqCode, resultCode, data);
  
      switch (reqCode) {
      case (PICK_CONTACT):
          if (resultCode == RESULT_OK) {
              Uri contactData = data.getData();
              ContentResolver cr = getContentResolver();
              Cursor c = cr.query(contactData, null, null, null, null);
              if (c.moveToFirst()) {
                  String id = c
                          .getString(c
                                  .getColumnIndexOrThrow(ContactsContract.Contacts._ID));
                  long cId = (long)Double.parseDouble(id);
  
                  String name = c
                          .getString(c
                                  .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                  int hasPhoneNumber = c
                          .getInt(c
                                  .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
  
                  if (hasPhoneNumber &gt; 0) {
                      // this contact
                      Cursor phoneCursor = cr
                              .query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                                      null,
                                      ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                              + "=?", new String[] { id },
                                      null);
                      while (phoneCursor.moveToNext()) {
                          String phoneNumber = phoneCursor
                                  .getString(phoneCursor
                                          .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                          Toast.makeText(getApplicationContext(),
                                  id + " " + name + " " + phoneNumber,
                                  Toast.LENGTH_LONG).show();
                      }
                      phoneCursor.close();
                  }
              }
          }
      }
  
  }
  </code></pre>