Hyas the audience in this theater we're going to go ahead and create another Android application and
connect our application to the firebase database.
So now let's create an android studio project and then here for the application and just typing here
at 65 and then click on next and he chews API 16 Android 4.1 jellybean for the minimum for the minimum
STK and then click on next and here choose empty activity next and here don't change anything.
So make sure that the activity name is main activity and the layout name is actually with the underlying
main.
So it's going to generate a file.
And that backwards compatibility is enabled and then click can finish.
So let's actually wait a little bit here.
So first of all we need to actually connect our application to the firebase database.
So at the top as you can see here just click on Tools and then click on firebase and now it can actually
open the fireplace assistant here for us.
So let's actually click on this real time database and then click on this save and retrieve data.
And now for the first step we just need to connect our application to the fireplace.
So just click on this button here connect to firebase.
So let's wait a little bit here.
As you can see it's SISC start connect starting connect dialog.
Right.
Now as you can see here that this window is open for us.
And now I just need to actually specify the name of the project.
And here it is create new firebase project right.
So if you want to connect your application to an already created a project you just need to check the
checkbox and choose an existing firebase or Google project and then you can actually connect your application
to one of your projects in firebase.
But for now we just want to create a new project right so that we can create new firebase project and
the name is at 65 and they can connect to firebase.
So let's wait a little bit here.
So now as you can see here our project is actually connected to Firebrace.
Right.
So now we should do the second step and it says at a real time database to your app.
So just click on the Spartan and in here or just accept changes here.
Just click on this access changes and it can actually add real time database to our application.
So let's wait a little bit here.
And now as you can see here is actually making our project ready for interacting with the firebase database.
So and as you can see here our project is now ready and here it says dependences set up correctly right.
So now let me collapse this assistant area and now let's actually DoubleClick and this is all they're
here and then doubleclick on its layout folder.
And now DoubleClick and this activity under the last minute example.
So now as you can see here we should actually design the user interface of our application.
So now let me double click on this tab here activity on the line I mean are they similar in order to
make this area wider and now less selectees hello world takes you here and now you want to design the
user interface of our application.
So here first of all let's actually click on this take step here at the bottom Atkins here we have this
Design tab and we have this text up.
So just click on this take step and now this actually change this relatively out to linear layout.
So just select is relatively here and just type in here linearly out with capital L and now as you can
see as you can see here at the bottom it actually changed this name to linearly out.
And now we need to specify the orientation of our linearly out because we have linearly.
Now we should actually specify an orientation for this linear out.
So here's distopian orientation.
So before the ending tag just type in orientation.
And now as you can see you can select this orientation attribute.
And here we have two options.
The first one is vertical and the second one is horizontal.
So for this project I want this vertical orientation for my linearly.
So just select it and then it's an interactive on your keyboard.
And now let's go back to our Design tab.
And as you can see here inside this componentry section we have actually a linearly out vertical line
right.
So first let's actually drag it textfield.
So inside takes wheels fall there it it takes it right just selectees plain text here and just track
it here into this linear layout vertical.
And now just select this text field here.
And for the idea just step in here it is the box Boxer name and that person energy on your keyboard.
And here as you can see we have this text attribute.
So just select this text value here and then delete this value.
And for the hint attribute to saving here.
Enter Boxer name dot dot dot and in person Enter key on your keyboard.
So Alice actually write another textfield into this linearly elsewhere.
So inside distastefulness Well it just select is plain text here and just drag it into this linearly
vertical.
And now for the idea just step in here.
EDT Boxer punch power.
Right and then present energy on your keyboard.
So for the text attributes it disvalue and for the hint just they've been here.
Enter punch power dot dot dot.
And in person until he on your keyboard.
And now it's actually a drag and either a plain text here.
This Titchfield into this linearly as vertical just select it and put it inside this linearly elsewhere
SD card and for the ID just step in here EDT Boxford punch speed and then press on until June your keyboard
and for the name attribute the list disvalue here.
And for the for the hint attribute the statement here.
Enter punch speed dot dot dot and then person enter here on your keyboard.
So now let's actually drag about him into this linearly Ellsworthy called Enceladus which is what a
just spot in here and just drag it here into this linearly as vertical.
Here below this textfield here and slaty spot in and for the ID just type in here between sent data
and then present Enter key on your keyboard.
And for the text attribute to step in here sent data to server and then person Enter key on your keyboard.
And now let's actually write up a vertical scroll view into this linearly.
I swear to god.
So just scroll down here inside the pallet section as you can see inside these containers fall there
as you can see just select this vertical scroll view here as you can see here to selected and dragged
into this linearly or 30 call and now inside these componentry section we have this scroll view and
inside this scroll view we have this linear area as well.
All right.
Just a selectees linearly out vertical here as you can see here.
Just an inside the palette section select is text view here right.
Select it and just drank it here into this linearly at vertical that is inside this scroll of view here
and now inside is linearly vertical that is inside of these scroll view.
We have this takes you right.
And for that for the id attribute of these takes you to step in here takes the received data and in
person and hit on your keyboard and just delete the text attribute as you can see here just delete the
value of this text attribute here and then person enter on your keyboard.
So now that we designed the user interface of our application.
So now let's actually go back to our main activity that double file here and now we can actually put
our own logic's here.
First of all let's actually create a new class so that is at the top just click on view to Windows and
then click on Project.
And here in this app folder and then I work on this job of all that and he has doubleclick on this package.
And here at the top click on File New and then click on Dobber class.
So for the name of our job a class just type in here Puck said with chapiter B and it actually can.
OK.
Soon as you can see here now we have this class boxer.
So let's actually double tap here in order to make this area wider.
And inside this class I'm going to actually put some lines of code here.
First of all let's actually create some instance variables.
So private and the data type of my variable is going to be strange and the name of my variable is Buxar
name right semicolon.
Let's create another instance variable private integer so that the data type of my variable is integer
and the name is a punch power semicolon.
In int and the name of my instance variable here is Ponch speed semicolon.
So now because you want to actually interact with our firebase database.
First of all you need to actually create an antique constructor.
This is very important.
We must create an empty constructor for our box of class because I want to actually send box objects
to the server.
Right.
So because of that first we need to create an empty constructor.
So here I can say public the access modifier of my constructor is public and the name of the constructor
must be the same as the name of the class.
And then I put a pair of pants here and it here.
I just need to open and close my constructor by using these curly braces.
So this is our empty constructor.
And now we actually should create another constructed in order to initialize our instance variables.
So here again I can't say or I can write it here or I can actually just Right-Click inside this class
and that here actually can generate.
And then he hopefully can constructor.
And now as you can see here we have this instance valuables right box or main punch power and punch
speed.
Just just select all these instance variables.
Just hold the shift key on your keyboard and select all these instance variables and then click on.
OK so now as you can see here are the Android studio Id created this constructor automatically for us
as you can see here.
Now inside it's constructed it is actually initializing these instance variables.
So you are already familiar with these constructors.
Right.
So now we should actually create get Herods for our instance variables.
So as you can see here these instance variables are private instance variables.
So we should create getters are in order to actually get the values in order to actually allow other
classes to get the values of our instance variables.
So here in say this class again I can just right click here.
And then we can generate and then we can get here and then he'll select all these instance variables
and then we can.
OK.
So as you can see here the Android studio ID automatically generated these lines of code for us right.
Kickboxer name pretend box of name get punch power return punch power and get punch speed return punch
speed.
So let's go to our main activity class.
And now inside this class.
First of all let's actually run our project now.
And here we should actually select our virtual device.
So I'm going to select this one and then click on OK.
So now as you can see here our application is running on the emulator.
So here we have free texts or text fields.
We have a button here and we also have a text view inside the scroll view.
So first let's actually create objects for these texts.
So inside this main activity class I'm going to just type in any text and the name of this first text
is going to be EDT box their name.
And now I just need to put a semicolon here or if I want to I can actually declare all these editor
access because these text fields are actually of the same type.
So I can't just declare them in one line of code here.
So here I can see edit text into boxes name karma.
And the second one is EDT punch power.
So here I can say EDT punch power right.
Comma the first one which is actually another edit text or text field.
Here I can say EDT ponse speed.
So here I can see the EDT Ponch speed.
So in this way we are actually declaring three objects of the same type text.
Right.
So if we have an object which is of type it it takes a little box and then we have another object which
is of the text and its name is EDT punch power and we have an other object which is of the text and
an image on speed.
Right.
So here we are declaring free objects of type.
Edit text.
Right.
So now here as you can see we have a button here I can see Button Pythian send data to set for semicolon
and we have actually a few inside are these are inside a vertical scroll view.
So here you can say takes few takes the received data semicolon.
And now let's actually go inside our uncreate Smurfette.
And now let's actually initialize these objects that we created here inside this main activity class.
So first of all this actually initialize this EDT box only.
So it is a boxer name.
Assignment operator is cast this object to it takes object find view by ID or that Id that EDT Boxer
the semicolon.
And now we have EDT punch power assignment operator.
And then I need to recast this object to an edit text object as you can see here.
You want to actually create an object of type every text.
Right.
Because I am referring to a user interface component inside our screen.
You need to have this object to an edit text object.
Right.
So here because I am actually finished with that object.
Are you going to assign that object to the EDT punch power.
Right.
This is actually a variable that holds an object of the text.
So here I can just say find view by ID or thought Id dot EDT.
Punch power semicolon and the next one is this one ADT upon speed.
So it it up on speed.
Assignment operator and here I need to cast this object to an edit text object find view by ID or that
Id dot EDT Ponch speed and then I need to put a semicolon at the end of my statement and the next one
is disputing Pythian send data to server.
So here I can't say BT and send data to a server assignment operator and then I need to test this object
to a button object as you can see here find view by the are that Id dot PTEN send data semi-colon and
the next one is this text view object.
It takes you a valuable actually.
So here you need to actually create an object that takes you.
So here I can see TXI the received data assignment operator.
And here I need to cast this object to our text view object find view by ID or thought Id dot takes
the received data semicolon.