0

This is the error. I tried a few things, but still got no results.

Process: com.lucastan96.flashchat, PID: 6114
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at com.lucastan96.flashchat.ChatListAdapter.getView(__ChatListAdapter.java:101__)
    at android.widget.AbsListView.obtainView(AbsListView.java:2366)
    at android.widget.ListView.makeAndAddView(ListView.java:2052)
    at android.widget.ListView.fillUp(ListView.java:820)
    at android.widget.ListView.layoutChildren(ListView.java:1793)
    at android.widget.AbsListView.onLayout(AbsListView.java:2165)
    at android.view.View.layout(View.java:20672)
    at android.view.ViewGroup.layout(ViewGroup.java:6194)
    boolean isMe = message.getAuthor().equals(mDisplayName);
    setChatRowAppearance(isMe, holder);

    String author = message.getAuthor();
    holder.authorName.setText(author);
    String msg = message.getMessage();
    holder.body.setText(msg);

    return convertView;

and the line 101 is at "boolean isMe = message.getAuthor().equals(mDisplayName);"

karel
  • 5,489
  • 46
  • 45
  • 50
ujuy
  • 3
  • 1

1 Answers1

0
boolean isMe = message.getAuthor().equals(mDisplayName); 

Here, message.getAuthor() is returning null. You can check it by debugging Solution: If you want the app to not crash you can use a try catch block for example:

try {
   boolean isMe = message.getAuthor().equals(mDisplayName);
   setChatRowAppearance(isMe, holder);
   String author = message.getAuthor();
   holder.authorName.setText(author);
   String msg = message.getMessage();
   holder.body.setText(msg);
}
catch (Exception e) {}
return convertView;