How to Send Data Back to MainActivity in Android using Kotlin?
As there are many methods to send the data, but in this article, we will use startActivityForResult() method. Here we need to launch a child activity using startActivityForResult() method. Then from child activity, we can easily send data back to Main Activity.
Note: To implement it in java refer to this article: How to send data from one activity to second activity using Java
Step by Step Implementation
Step 1: Create new project in android using kotlin
Step 2: Create XML layout for MainActivity
Step 3: Below is the code for MainActivity.kt file
Step 4: XML for child activity
Step 5: Following code for ChildActivity.kt file
So our app is ready.
My Personal Notes arrow_drop_up
Please Login to comment...