Solution 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")
Problem :
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
Comments
Comment posted by How do I pass data between Activities in Android application?
Does this answer your question?
Comment posted by Sam Spencer
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?
Comment posted by Ayush Dubey
is “phoneNumber” the id of the view?
Comment posted by Bita Mirshafiee
This is a key for the phonenumber that you want to pass to the second activity and retrieve it there
Comment posted by Ayush Dubey
Ok, thanks .. and in the next activtity view .. just display android_text=”@string/myPhoneNumber” .right? {In the XML file}
Comment posted by Bita Mirshafiee
No you need to set it in your activity after retrieving it like: mytextView.text = phoneNumber