title: How to pass a string from a list in one activity to another
body: <p>What I would like to do is convert the list of user into a string and on click pass the selected string to the next activity. I tried this on a messaging feature I have used on the app and it has worked fine. Now I am attempting to work with a gallery feature. What this section is supposed to do is find all the users in parse, convert them to string and display them on the list view. On click it is supposed to collect the string on the list and use it in the gallery view activity to display all the images where the username is equal the one selected from the list.</p>
  
  <p><strong>ListUserActivity</strong></p>
  
  <p>List view of all the usernames saved in the database.</p>
  
  <pre><code>//display clickable a list of all users
  private void setConversationsList() {
      currentUserId = ParseUser.getCurrentUser().getObjectId();
      names = new ArrayList&lt;String&gt;();
  
      ParseQuery&lt;ParseUser&gt; query = ParseUser.getQuery();
      query.whereNotEqualTo("objectId", currentUserId);
      query.findInBackground(new FindCallback&lt;ParseUser&gt;() {
          public void done(List&lt;ParseUser&gt; userList, com.parse.ParseException e) {
              if (e == null) {
                  for (int i=0; i&lt;userList.size(); i++) {
                      names.add(userList.get(i).getUsername().toString());
                  }
  
                  usersListView = (ListView)findViewById(R.id.usersListView);
                  namesArrayAdapter =
                          new ArrayAdapter&lt;String&gt;(getApplicationContext(),
                                  R.layout.user_list_item, names);
                  usersListView.setAdapter(namesArrayAdapter);
  
                  usersListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                      @Override
                      public void onItemClick(AdapterView&lt;?&gt; a, View v, int i, long l) {
                          openConversation(names, i);
                      }
                  });
  
              } else {
                  Toast.makeText(getApplicationContext(),
                          "Error loading user list",
                          Toast.LENGTH_LONG).show();
              }
          }
      });
  }
  </code></pre>
  
  <p>What happens on clicking the name on the list view.</p>
  
  <pre><code>public void openConversation(ArrayList&lt;String&gt; names, int pos) {
      ParseQuery&lt;ParseUser&gt; query = ParseUser.getQuery();
  
      query.whereEqualTo("username", names.get(pos));
      query.findInBackground(new FindCallback&lt;ParseUser&gt;() {
          public void done(List&lt;ParseUser&gt; user, com.parse.ParseException e) {
              if (e == null) {
                  // Intent intent = new Intent(getApplicationContext(), GridActivity.class);
                  Intent intent = new Intent(ListUsersActivity.this, GridActivity.class);
                  intent.putExtra("RECIPIENT_ID", user.get(0).getObjectId());
                  startActivity(intent);
              } else {
                  Toast.makeText(getApplicationContext(),
                          "Error finding that user",
                          Toast.LENGTH_SHORT).show();
              }
          }
      });
  }
  </code></pre>
  
  <p><strong>GalleryActivity</strong></p>
  
  <p>I've tried to convert the <strong>RECIPIENT_ID</strong> to a string variable called <strong>recipientId</strong> and add it in the line <code>query.whereEqualTo("username", recipientId);</code> but it keeps creating a message telling me it is NULL.</p>
  
  <pre><code> @Override
      protected Void doInBackground(Void... params) {
          // Create the array
  
          Intent intent = getIntent();
          recipientId = intent.getStringExtra("RECIPIENT_ID");
          currentUserId = ParseUser.getCurrentUser().getObjectId();
  
  
          phonearraylist = new ArrayList&lt;PhoneList&gt;();
          try {
  
              ParseQuery&lt;ParseObject&gt; query = new ParseQuery&lt;ParseObject&gt;("ImageUpload");
  
  
              usernametxt = usernameimgshow.getText().toString();
              //query.whereEqualTo("username", userstr);
              query.whereEqualTo("username", recipientId);
              query.orderByAscending("createdAt");
              ob = query.find();
              for (ParseObject country : ob) {
                  ParseFile image = (ParseFile) country.get("ImageFile");
                  PhoneList map = new PhoneList();
                  map.setPhone(image.getUrl());
                  phonearraylist.add(map);
              }
          } catch (ParseException e) {
              Log.e("Error", e.getMessage());
              e.printStackTrace();
          }
          return null;
      }
  </code></pre>