Search code examples
androidmaterial-components-androidmaterial-components

I want to display the phone number entered by user during signup in the next activity


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


Solution

  • 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")