-3

screenshot 2screen 1Here is what I have tried so far.

 public voi[screenshot 3][3]d onDataChange(@NonNull DataSnapshot dataSnapshot)
        {
            if (dataSnapshot.child(receiverUserId).exists()) {
                receiverUserImage = dataSnapshot.child(receiverUserId).child("image").getValue().toString();
                receiverUserName = dataSnapshot.child(receiverUserId).child("name").getValue().toString();

                nameContact.setText(receiverUserName);
                Picasso.get().load(receiverUserImage).placeholder(R.drawable.profile_image).into(profileImage);

            }
            if (dataSnapshot.child(senderUserId).exists()) {
                senderUserImage = dataSnapshot.child(senderUserId).child("image").getValue().toString();
                senderUserName = dataSnapshot.child(senderUserId).child("name").getValue().toString();
            }

        }

Below is what I get from the debug log.

DEBUG LOG
  at com.studio.asinsta.CallingActivity$3.onDataChange(CallingActivity.java:111)
        at com.google.firebase.database.core.ValueEventRegistration.fireEvent(com.google.firebase:firebase-database@@19.2.1:75)
        at com.google.firebase.database.core.view.DataEvent.fire(com.google.firebase:firebase-database@@19.2.1:63)
        at com.google.firebase.database.core.view.EventRaiser$1.run(com.google.firebase:firebase-database@@19.2.1:55)

Any help is appreciated.

1 Answers1

0

Your problem is that the textview you are trying to set text for is null.

This is pointed out by the following line :

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.studio.asinsta, PID: 31586 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference at 

I would make sure nameContact (your textview) is being correctly found by it's id (since you have not provided the code that shows how you achieve this).

nameContact.setText(receiverUserName);

tomerpacific
  • 4,704
  • 13
  • 34
  • 52