
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val btn = findViewById<Button>(R.id.testBtn) | |
btn.setOnClickListener { | |
val intent = Intent(this, MainActivity2::class.java) | |
val testClass = TestClass() | |
testClass.test1 = "test1" | |
testClass.test2 = "test2" | |
intent.putExtra("TestClass", testClass as Serializable) | |
startActivity(intent) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestClass ( | |
var test1: String? = "", | |
var test2: String? = "" | |
) : Serializable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity2 : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main2) | |
val getObject = intent.extras?.get("TestClass") as TestClass | |
Log.e("Act2", getObject.toString()) | |
Log.e("Act2", getObject.test1) | |
Log.e("Act2", getObject.test2) | |
} | |
} |
'Android(Kotlin)' 카테고리의 다른 글
Andorid notification - 1 (0) | 2021.04.24 |
---|---|
kotlin apply (0) | 2021.04.24 |
Retrofit, Coroutine - 7 (0) | 2021.04.23 |
Retrofit, Coroutine - 6 (0) | 2021.04.23 |
Retrofit, Coroutine - 5 (0) | 2021.04.23 |