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 Viewing Video Messages

App crashes AFTER viewing videos but not photos. Not able to return to inbox Fragment

Getting a null pointer exception on Message Adapter class after being able to watch a video.

The error is pointing to my Message adapter class, where it's loading the media icon depending on the KEY_FILE_TYPE.

    if (message.getString(ParseConstants.KEY_FILE_TYPE).equals(ParseConstants.TYPE_IMAGE)) {
    } else {

This error isn't happening when the inbox fragment initially loads, nor when returning from viewing an image.

Here is my InboxFragment on resume method:

@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) {
                //success... 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);
                MessageAdapter adapter = new MessageAdapter(getListView().getContext(), mMessages);