Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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);