E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.shopingonline, PID: 18327
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.shopingonline/com.example.shopingonline.HomeActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.example.shopingonline.Model.Users.getName()' on a null object reference
View headerView = navigationView.getHeaderView(0);
TextView userNameTextView = headerView.findViewById(R.id.user_profile_name);
CircleImageView profileImageView = headerView.findViewById(R.id.user_profile_image);
userNameTextView.setText(Prevalent.currentOnlineUser.getName());
public class Prevalent {
public static Users currentOnlineUser;
//unique key for all users
public static final String UserPhoneKey = "UserPhone";
public static final String UserPasswordKey = "UserPassword";
}
public class Users {
//get the name passeword, all the user information
private String name, phone, password;
public Users(String name, String phone, String password) {
this.name = name;
this.phone= phone;
this.password = password;
}
public Users(){
};
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
} public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
// i have this problem and i can't resolve it i tried for 4 days but it's so hard for me as beginner gjvkhkbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb