Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Retrieving and Viewing Messages Retrieving Messages

No messages retrieved

I am a bit stuck. I've followed the tutorial to the letter but I do not receive messages in the app. My account on parse.com shows the messages but my app inbox show the "no new messages" text.

Here is the code for the inboxfragment

package uk.co.petipois.ribbit;

import java.util.List;

import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.parse.FindCallback; import com.parse.ParseException; import com.parse.ParseObject; import com.parse.ParseQuery; import com.parse.ParseUser;

public class InboxFragment extends ListFragment {

protected List<ParseObject> mMessages;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_inbox, container,
            false);

    return rootView;
}

@Override
public void onResume() {
    super.onResume();

    getActivity().setProgressBarIndeterminateVisibility(true);

    ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(ParseConstants.CLASS_MESSAGES);
    query.whereEqualTo(ParseConstants.KEY_RECIPIENT_IDS, ParseUser.getCurrentUser().getObjectId());
    query.addDescendingOrder(ParseConstants.KEY_CREATED_AT);
    query.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> messages, ParseException e) {
            getActivity().setProgressBarIndeterminateVisibility(false);

            if (e == null) {
                // We found messages!
                mMessages = messages;

                String[] usernames = new String[mMessages.size()];
                int i = 0;
                for(ParseObject message : mMessages) {
                    usernames[i] = message.getString(ParseConstants.KEY_SENDER_NAME);
                    i++;
                }
                MessageAdapter adapter = new MessageAdapter(
                        getListView().getContext(), 
                        mMessages);
                setListAdapter(adapter);
            }
        }
    });
}

}

3 Answers

Patrick Donahue
Patrick Donahue
9,523 Points

This is an idea - but when I was doing the same project for iOS I misspelled one of the parse.com column names in my code. So you may want to check your keys to make sure they are the same in parse.com and in your code. Hope this helps! :-)

thanks. i'll try that

Belinda D
Belinda D
3,783 Points

Check that the MessageAdapter Class matches the lecturers code as we'll. I had the same issue where messages weren't showing up in my Inbox, the problem was that I was missing the word 'messages' in the 'super' row.

super(context, R.layout.message_item, messages);