Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get string extra from activity Kotlin

Tags:

android

kotlin

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

like image 767
zasaz Avatar asked Jul 16 '17 19:07

zasaz


People also ask

How do you get extra strings?

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.


1 Answers

Answer found, in the next activity, you have to do this to get the string:

val ss:String = intent.getStringExtra("samplename").toString() 
like image 54
zasaz Avatar answered Oct 04 '22 17:10

zasaz