MainActivity.kt
PutExtra(String!.String?) is givng error (in android Kotlin), what could be the problem?
class MainActivity : AppCompatActivity()
{
override fun onCreate(savedInstanceState: Bundle?)
{
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
var name:EditText? = null
fun createBirthdayCard(view: View) {
name = findViewById(R.id.NameInput)
val intent = Intent(this,BirthdayGreetActivity::class.java)
intent.putExtra(BirthdayGreetActivity.NAME_EXTRA,name)
startActivity(intent)
}
}
2
Answers
when sending data
when receiving data
this line of yours adds NameInput to intent not string. I dont know what your NameInput is but you may try name.text. Maybe if you gave the code of NameInput I might help better.