code: @Nullable
      public static Data onResult(@NonNull Context context, int resultCode, @Nullable Intent data) {
          if (resultCode != Activity.RESULT_OK || data == null || data.getData() == null) {
              return null;
          }
  
          Cursor cursor = null;
          try {
              cursor = context.getContentResolver().query(data.getData(),
                      new String[] {
                              ContactsContract.CommonDataKinds.Phone.CONTACT_ID,
                              ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
                              ContactsContract.CommonDataKinds.Phone.NUMBER
                      },
                      null, null, null);
  
              if (cursor != null && cursor.moveToFirst()) {
                  return new Data(cursor.getInt(0), cursor.getString(1), cursor.getString(2));
              }
          } finally {
              if (cursor != null) {
                  cursor.close();
              }
          }
  
          return null;
      }
docs: Call this method from {@link Activity#onActivityResult(int, int, Intent)} method to
  get picked contact info.