‫In this video, we'll initialize the views of the second activity and generate random numbers.
‫Let's start by the views.
‫Don't miss.
‫Import the class, the button and the text view in the Oncreate method.
‫I'll find the views by using the find view by ID method.
‫In the previous video, we learned how to pass the name to second activity, how to pass a string to
‫a second activity using the put extra.
‫In this video, we'll learn how to receive the data and store them into specific variables.
‫So I'm using again intent instance I equal to get intent.
‫This method allows us to get the key value pairs that are stored in the put extra method get intent
‫method will retrieve this key and value pairs the name and the value of it, which is the username.
‫Get it from the edit text Alt+.
‫Enter to import the intent class.
‫Then I need to get this intent and store it inside a username string equal.
‫I dot get string extra.
‫What is the key?
‫The key here is the name, so I'll copy it because it's a case sensitive.
‫So pay attention to this guys.
‫Here I get the intent information, getting all the data.
‫Then I am getting here the I dot get and string extra.
‫I am specifying the key in order to get the value and store it inside the user name variable.
‫This is how we get the data from intent from the main activity.
‫Now let's move to generate random numbers and learn about the random class.
‫I'll create a new function called Generate random number.
‫I'll start by creating an instance from a random class which is in Java.
‫I'll name it as random equal to new random.
‫The random class in Android is a part of the Java Standard Library and is used to generate random numbers
‫and random data.
‫It allows you to create instances that can generate pseudo random numbers using various algorithms.
‫In Android you can use random class to generate random numbers for various purposes, such as generating
‫random values for testing, creating random game scenarios, shuffling lists and more.
‫I'll start defining the upper limit, which is the maximum number that this random class can generate
‫numbers up to it, which is 1000.
‫I'll start with int random number generated.
‫I'm going to store the random number generated from the random class into random number generated variable.
‫Random dot next int.
‫And here I specify the upper limit that the random class can generate, so it will generate random from
‫zero up to 1000.
‫And then I return this random number generated because the returning type of this method is int.