How to pass the values from activity to another activity in kotlin

Send value from HomeActivity

val intent = Intent(this@HomeActivity,ProfileActivity::class.java)
intent.putExtra("Username","John Doe")
startActivity(intent)

Get values in ProfileActivity

val profileName=intent.getStringExtra("Username")

I'm on mobile, you must test by yourself.

Try to make a CharSequence to a String in MainActivity , you have put a CharSequence rather than a String, for example:

var userName = username.text.toString()
var password = password_field.text.toString()

In Kotlin, you can pass the data simply by using the Intents. You can directly put your data in intent or you can write those data in bundle and send that bundle to another activity using the intent.

val intent = Intent(this@HomeActivity,ProfileActivity::class.java);
intent.putExtra("profileName", "John Doe")
var b = Bundle()
b.putBoolean("isActive", true)
intent.putExtras(b)
startActivity(intent);