I want to get a string extra in another activity from an intent. This is the way to create my intent
val intent = Intent(this, Main2Activity::class.java) intent.putExtra("samplename", "abd") startActivity(intent)
How can i get the value of this intent in the another activity
We can use the Intent. getExtras() in the target activity/class to get the attached bundle and extract the data stored in it. String user_name = extras.
Answer found, in the next activity, you have to do this to get the string:
val ss:String = intent.getStringExtra("samplename").toString()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With