title: Callback timing
body: <p>Hey everyone happy upcoming turkey day !. So I am trying to implement a search manager class that handles all searching for this android app using a parse backend and ran into an interesting problem. Here is the method that should call the search managers search function</p>
  
  <pre><code>public void SearchForLostItems(){
  
      String searchtext = mSearchView.getQuery().toString();
  
      List&lt;ParseObject&gt; foundposts =  mSearchManager.BasicSearch(searchtext);
  
  
  
          //if we found a matching post go to the post details
                  if(parseObjects != null){
  
                      //Try to get our found posts count if there is more than one match than list them for the user and let them browse
                      try {
  
                          //if there is only one match then go ahead to the post
                          if(parseObjects.size() == 1){
  
                              ParseObject foundpost = parseObjects.get(0);
  
                              Post post = new Post(foundpost.getObjectId(), "");
  
                              GoToFoundPost(post);
                          }
  
                      } catch (ArrayIndexOutOfBoundsException ex) {
                          e.printStackTrace();
                      }
  
                  }
              }
              else
              {
                  e.printStackTrace();
              }
  
          }
  
      });
  
  }  
  </code></pre>
  
  <p>And here is the implementation in search manager </p>
  
  <pre><code>//Basic search for when someone searches by text, should accept some search text and returhn amatched list of parse objects
  public List&lt;ParseObject&gt;BasicSearch(String searchtext){
  
      final List&lt;ParseObject&gt; PostsHolder = null;
  
      //Do a search for all posts that contain the search text
      ParseQuery&lt;ParseObject&gt; foundposts = new ParseQuery&lt;ParseObject&gt;(ParseConstants.CLASS_POSTS); // get the whole class
  
      foundposts.whereEqualTo(ParseConstants.POST_TITLE,searchtext); // filter the results based on the search text
  
       foundposts.findInBackground(new FindCallback&lt;ParseObject&gt;() { //call the find in background routine to convert the results to a list
          @Override
          public void done(List&lt;ParseObject&gt; parseObjects, ParseException e) {
  
              if(e == null){
                  PostsHolder.addAll(parseObjects);
                  Log.d("Posts Added", "true");
  
              }
              else
              {
                  e.printStackTrace();
              }
  
          }
  
      });
  </code></pre>
  
  <p>return PostsHolder;</p>
  
  <p>}</p>
  
  <p>I think this issue is because the function returns before the callback is complete but I am not sure for java and specifically android.</p>
  
  <p>As always thanks for all the help ! </p>