i.e when the user enters his/her phone number ,the next activity should say : WE HAVE SENT AN OTP TO YOUR NUMBER ( WHERE INSTEAD OF NUMBER , IT SHOULD DISPLAY THE PHONE NUMBER ENTERED BY USER ) FOR MY ANDROID APP
Asked
Active
Viewed 40 times
-3
-
Does this answer your question? [How do I pass data between Activities in Android application?](https://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android-application) – AgentP Jun 07 '20 at 16:48
-
Hi Ayush! Welcome to StackOverflow! Your question is a little hard to understand without more context. Would you mind editing your question to add more detail on what you've already tried to do and what specific problems you're running into? – Sam Spencer Jun 07 '20 at 17:25
1 Answers
1
open a new activity and send data through intent like this in your first activity :
val intent = Intent(context, MySecondActivity::class.java)
intent.putExtra("phoneNumber", myPhoneNumber)
context.startActivity(intent)
then in your second activity in onCreate():
phoneNumber = intent.extras?.getParcelable("phoneNumber")

Bita Mirshafiee
- 600
- 8
- 14
-
-
This is a key for the phonenumber that you want to pass to the second activity and retrieve it there – Bita Mirshafiee Jun 07 '20 at 18:13
-
Ok, thanks .. and in the next activtity view .. just display android:text="@string/myPhoneNumber" .right? {In the XML file} – Ayush Dubey Jun 07 '20 at 18:14
-
No you need to set it in your activity after retrieving it like: mytextView.text = phoneNumber – Bita Mirshafiee Jun 07 '20 at 18:16