I want to display the name, what happens is that the name cannot be displayed or null. Here I use getParcelableExtra, I think my code still has errors, but I don't understand where the error is.
this is the function that will display the name
private fun receiveData() {
val user = activity?.intent?.getParcelableExtra<LoginNewResponse>("EXTRA_NAME")
binding.tvName.text = user?.result?.name
}
this is a variable in the LoginActivity.kt
val intent = Intent(this, DashboardActivity::class.java).also {
it.putExtra("EXTRA_NAME", data.result.name)
startActivity(it)
}
and the last, this is the LoginResponse
@Parcelize
data class LoginNewResponse(
@field:SerializedName("result")
val result: LoginResult,
@field:SerializedName("error")
val error: Boolean,
@field:SerializedName("message")
val message: String
) : Parcelable
@Entity(tableName = "login")
@Parcelize
data class LoginResult(
@field:SerializedName("role")
val role: String,
@field:SerializedName("name")
val name: String,
@field:SerializedName("userId")
val userId: String,
@field:SerializedName("email")
val email: String,
@field:SerializedName("token")
val token: String
) : Parcelable
I don't know where the error is
Thankyou for the answer