And another important point that I want to talk about here is that look at this class here look at the
name of this class.
This class is actually created by ourselves right.
The name of this class is net 14:4.
And in fact we have another class in Android that nets package with this same name network info.
So as you can see here in length 17 I am actually using that class that is actually inside the android
that nets package.
So at the Android studio as you can see here is going to actually differentiate between these two classes.
This is our own class and this is actually class that is inside of the Android that net package.
So that's why the Android studio put this android dot net here in order to differentiate between these
two classes.
OK.
So in line 17 are you want to use the network in for class that is actually inside the Android database
package.
And here as you can see we have this network in for this class is actually created by ourselves.
OK.
And hopefully we can understand what's going on here and here I just wanted to show you that it is actually
referring to a class inside the android that nets package.
And because this class the class that actually that is created by ourselves and this who has that is
inside of this inside of the Android that package is the same name they have the same name here as you
can see the Android studio put this android in package in order to differentiate between these two classes.
This is actually the class that is inside of you and that net package.
And this is the class that is created by me.
OK.
So hopefully that makes sense.
And here I created an if statement as you can see here if network info is not equal to null.
OK.
If this value is not equal to a null.
OK.
Now again I actually created a switch statement.
So through each network info that get type.
So now I can actually switch between the types of these network info object as you can see here case.
So if the connectivity manager type voice fine.
So if the device is actually connected to the Internet revivify return number one.
So now let's actually hold the Komansky.
So if you are using end of Windows machine hold the control key and then click on this get type here.
Network in for that type.
And as you can see here the Smurfette here that is inside of this network info the Java file.
As you can see this method this is DMF it right.
And this Linforth returns an integer value as you can see here.
OK.
So let's go back to our network in for the double file here.
So because this it returns an integer value here you're actually switching between the values of this
Meffert get type.
OK.
So if the connectivity manager that type will be fine.
So again let's hold the Command key.
And if you are using a Windows machine hold the control key and then click on this type Wi-Fi here.
And as you can see here now I mean to say this our connectivity manager that drove a fight and here
I have this constant And as you can see type of lifeI here holds the value number one.
And here as you can see in line three hundred and thirty two these type Moabite as you can see Haught
as you can see here holds the values zero.
OK.
And as you can see here we have other constants type mobile EMIs and type more by S U P L type more
by the UN and other constants here that you can use in your project.
So here here I am saying that if the connectivity manager the type verify then return number one.
OK.
And case connectivity manager that tape more bite.
So if the device is actually connected to the Internet from Mobile they'll return number two.
OK.
All I can say that the return number is zero.
So as you can see here if I hold the comment chip and then click on this type mobile here this type
mobile actually holds this value number zero.
OK.
So I can actually return the value zero OK or default.
And this means that the device is actually connected to the Internet through other technologies.
So here I just returned number three.
OK.
I'm not going to actually create some case statements for that for those kinds of technologies but but
here are creating two case statements for a wife and mobile.
OK.
And here as you can see I have this Else statement that is actually related to this.
If the to this statement and this means that if network info is equal to null and this means that we
are not actually connected to the Internet at all then it's going to return to zero.
So here I can say that return for example number one thousand and this means that the device is actually
not actually connected to the Internet at all.
OK.
So this is how you actually specify that whether your device is actually connected to the Internet or
not.
And what is going to be the type of the Internet.
OK Wi-Fi or type more bite.
So let's go inside.
Our main activity that you will find here unless I try to use this class is network class the Java file.
So now inside is unclear.
Meffert that is inside of these main activity class that's actually going to actually be pasting some
lines of code here and then I'm going to explain to you what's going on here.
So as you can see here these are the lines of code that I actually pasted here.
OK so now I'm going to explain to you what's going on here.
So in line 45 as you can see I actually created a body of type integer right and the name of this variable
is status infl assignment operator.
As you can see here.
So here I called this a class network in Forth I've referred to the name of this class networth info
that gets network status.
So here I am actually calling this static method that is inside of this network info class.
So let's ask you to go inside this networking for the terrified and as you can see here inside this
class that's network info I have the Smurfette which is actually static gets network status and this
method returns a value of that integer.
OK so that's why insight is sweetest statement.
I am actually returning these values if the device is actually connected to the Internet for Wi-Fi then
it does me if it is going to return the value number one then.
Or if the device is actually connected to the Internet flew mobile dentist if is going to return the
value number to zero or if the device is actually connected to the Internet through other technologies
that then it's going to get you to retain the value number is free.
OK.
And if the actually device is not actually connected to the Internet at all then it's going to returned
a value a number one thousand.
OK so let's go back to our main activity that I've offered here.
So this is going to return a value of the integer and this method actually to assets of value of type
context.
So the past is context main activity that this and he had created us some if else statements here.
So here I have this if statement so if status in for if this valuable integer is equal to number 1.
So this means that our device is actually connected to the internet for a wife.
Right.
So here I actually referred to the name of this.
I imagine it's work type here.
I imagine it's worked like that.
Image triable get resources that get triable are that triable that Whyfor Internet.
So here I am referring to the triable folder inside my resources and and here I am actually referring
to the name of this image are that triable that Whyfor Internet as you can see here in my project structure
inside the tribal folder.
I have this mobile internet that PNB and Wi-Fi Internet that PNB OK.
So you have these two images.
In my project and here I am really fairly image to the name of this Wi-Fi Internet here.
As you can see so now here again I am actually creating a toast object in order to let the user know
that the device is actually connected to the Internet for wifely Wi-Fi Internet.
And here I have an AS IF statement so if status info is equal to number zero.
And this means that the device is actually connected from the Internet to the Internet through more
wide.
So again I am doing network time.
That said IMET triable said image triable get resources that get triable are triable that more by Internet.
OK.
And he had created a toast object toast that make takes and this is their first argument this is going
to be the second argument.
Mobile internet and this is the land line shortcut show.
And here I have an else statement and this means that if the device is actually connected to the Internet
of other technologies or that device is not actually connected to the Internet at all then it is going
to execute this or else statement here.
So inside this I am inside this Ellis statement.
I imagine it's for type that said Image resource.
Art that's me pass me.
Map that see Lanter.
OK.
And then in line 55 TOSed that make text the main activity that this and the taste that is going to
be shown to the user is unknown and the land is short and it is going to be shown to the user.
OK.
So this I.S. launcher is actually the image that we have in our project as the actually the image of
the icon of the application.
So as you can see here in my project structure in say displays folder I have this map directory here.
So inside this map directory I have these I.S. lunchers here as you can see with different qualities
as you can see here.
OK.
So I just referred to the name of this image in my main activity class in order to let the user know
that the technology is unknown or the user is not actually connected to the Internet or I can actually
create another else if statement in order to actually see whether that whether the device is actually
connected to the Internet for all other technologies.
So I can actually create an else if statement and check for them.
These are networks that this is actually equal to number three as you can see here.
This status info is equal to number of.
Then I can actually create a toast or actually set on an image to the image for you and let the user
know that the device is actually connected to the Internet.
And it is actually using other technologies.
OK.
So hopefully that makes sense.
And now let's actually run our project and see what happens.
So as you can see here our application is running on this emulator right.
So let's actually click on the spot and let's see what happens.
And now as you can see our application actually crashed and the answer there isn't that this application
is actually crashed is actually inside this manifest here inside this android manifested.
Example here when you actually put some permissions.
So inside this manifest tag as you can see here inside this manifest tag I need to put some permissions.
So here I just need to open a tag.
And then here I just need to type in user's permission and first of all I need to access the wife by
state and that I need to close this permission here and then here I need to actually access the Internet.
So here I need to actually type in users permission and here I just need to type in Internet and then
I need to close this permission this attack.
I need to put this closing tag here or I could actually use self-closing.
So here I could just typing here slash and this and this is a closing tag here as you can see.
And in this way I am actually close in this attack here or I can actually use this one here in this
way I could actually close the stack.
OK.
And now I could actually I need to actually add another permission so I need to typing I need to put
this open in tag here and then I just need to type in user's permission.
And here I need to type pean.
Network.
Network Access Network state.
OK.
So here I just need to close this up Hermitian here is attached here.
So as you can see here I need to put these permissions here.
OK.
And I need to ask the user that you want to actually access this permissions.
OK I need to access these features access by state access this internet and access networks.
OK.
So let's run our project again and see what happens.
So as you can see here our application is running on this emulator here.
So let's actually click on this network status button here and now as you can see it says mobile internet
and we have this image here more wide.
OK.
So this device this emulator is actually connected to the Internet from Mobile not qualify.
OK.
So you can actually do it on this application on your actual device and you can actually see the results
there.
So hopefully that makes sense and I think that's enough for this tutorial so if you have any questions
please post the discussion in the course and then I'll do my best to answer all of your questions.
Thank you very much for watching and I'll see you in the next tutorial.