1
00:00:00,660 --> 00:00:06,450
And another important point that I want to talk about here is that look at this class here look at the

2
00:00:06,450 --> 00:00:07,650
name of this class.

3
00:00:07,710 --> 00:00:10,110
This class is actually created by ourselves right.

4
00:00:10,140 --> 00:00:12,410
The name of this class is net 14:4.

5
00:00:12,690 --> 00:00:19,050
And in fact we have another class in Android that nets package with this same name network info.

6
00:00:19,230 --> 00:00:25,820
So as you can see here in length 17 I am actually using that class that is actually inside the android

7
00:00:25,830 --> 00:00:27,130
that nets package.

8
00:00:27,390 --> 00:00:33,690
So at the Android studio as you can see here is going to actually differentiate between these two classes.

9
00:00:33,720 --> 00:00:38,770
This is our own class and this is actually class that is inside of the Android that net package.

10
00:00:38,790 --> 00:00:45,840
So that's why the Android studio put this android dot net here in order to differentiate between these

11
00:00:45,840 --> 00:00:46,640
two classes.

12
00:00:46,740 --> 00:00:47,230
OK.

13
00:00:47,370 --> 00:00:54,270
So in line 17 are you want to use the network in for class that is actually inside the Android database

14
00:00:54,310 --> 00:00:55,310
package.

15
00:00:55,590 --> 00:01:00,470
And here as you can see we have this network in for this class is actually created by ourselves.

16
00:01:00,480 --> 00:01:01,190
OK.

17
00:01:01,560 --> 00:01:07,260
And hopefully we can understand what's going on here and here I just wanted to show you that it is actually

18
00:01:07,590 --> 00:01:11,350
referring to a class inside the android that nets package.

19
00:01:11,490 --> 00:01:17,320
And because this class the class that actually that is created by ourselves and this who has that is

20
00:01:17,320 --> 00:01:22,470
inside of this inside of the Android that package is the same name they have the same name here as you

21
00:01:22,470 --> 00:01:29,190
can see the Android studio put this android in package in order to differentiate between these two classes.

22
00:01:29,220 --> 00:01:32,280
This is actually the class that is inside of you and that net package.

23
00:01:32,430 --> 00:01:35,510
And this is the class that is created by me.

24
00:01:35,520 --> 00:01:36,150
OK.

25
00:01:36,690 --> 00:01:39,100
So hopefully that makes sense.

26
00:01:39,390 --> 00:01:46,850
And here I created an if statement as you can see here if network info is not equal to null.

27
00:01:46,970 --> 00:01:47,860
OK.

28
00:01:48,240 --> 00:01:50,350
If this value is not equal to a null.

29
00:01:50,550 --> 00:01:51,000
OK.

30
00:01:51,060 --> 00:01:55,110
Now again I actually created a switch statement.

31
00:01:55,110 --> 00:01:57,950
So through each network info that get type.

32
00:01:58,020 --> 00:02:04,290
So now I can actually switch between the types of these network info object as you can see here case.

33
00:02:04,290 --> 00:02:07,190
So if the connectivity manager type voice fine.

34
00:02:07,200 --> 00:02:12,590
So if the device is actually connected to the Internet revivify return number one.

35
00:02:12,600 --> 00:02:16,530
So now let's actually hold the Komansky.

36
00:02:16,530 --> 00:02:22,130
So if you are using end of Windows machine hold the control key and then click on this get type here.

37
00:02:22,220 --> 00:02:24,310
Network in for that type.

38
00:02:24,660 --> 00:02:29,710
And as you can see here the Smurfette here that is inside of this network info the Java file.

39
00:02:30,000 --> 00:02:32,290
As you can see this method this is DMF it right.

40
00:02:32,400 --> 00:02:36,360
And this Linforth returns an integer value as you can see here.

41
00:02:36,360 --> 00:02:36,950
OK.

42
00:02:37,230 --> 00:02:40,700
So let's go back to our network in for the double file here.

43
00:02:40,710 --> 00:02:46,560
So because this it returns an integer value here you're actually switching between the values of this

44
00:02:46,560 --> 00:02:47,980
Meffert get type.

45
00:02:48,030 --> 00:02:48,500
OK.

46
00:02:48,720 --> 00:02:51,810
So if the connectivity manager that type will be fine.

47
00:02:51,930 --> 00:02:54,070
So again let's hold the Command key.

48
00:02:54,240 --> 00:03:00,100
And if you are using a Windows machine hold the control key and then click on this type Wi-Fi here.

49
00:03:00,360 --> 00:03:05,280
And as you can see here now I mean to say this our connectivity manager that drove a fight and here

50
00:03:05,310 --> 00:03:11,560
I have this constant And as you can see type of lifeI here holds the value number one.

51
00:03:12,000 --> 00:03:17,270
And here as you can see in line three hundred and thirty two these type Moabite as you can see Haught

52
00:03:17,580 --> 00:03:19,770
as you can see here holds the values zero.

53
00:03:20,040 --> 00:03:20,740
OK.

54
00:03:21,030 --> 00:03:28,860
And as you can see here we have other constants type mobile EMIs and type more by S U P L type more

55
00:03:28,860 --> 00:03:33,390
by the UN and other constants here that you can use in your project.

56
00:03:33,390 --> 00:03:39,630
So here here I am saying that if the connectivity manager the type verify then return number one.

57
00:03:40,070 --> 00:03:40,920
OK.

58
00:03:41,280 --> 00:03:44,650
And case connectivity manager that tape more bite.

59
00:03:44,670 --> 00:03:49,910
So if the device is actually connected to the Internet from Mobile they'll return number two.

60
00:03:50,160 --> 00:03:50,700
OK.

61
00:03:50,700 --> 00:03:53,130
All I can say that the return number is zero.

62
00:03:53,130 --> 00:03:57,900
So as you can see here if I hold the comment chip and then click on this type mobile here this type

63
00:03:57,900 --> 00:04:00,500
mobile actually holds this value number zero.

64
00:04:00,720 --> 00:04:01,260
OK.

65
00:04:01,260 --> 00:04:06,090
So I can actually return the value zero OK or default.

66
00:04:06,090 --> 00:04:11,340
And this means that the device is actually connected to the Internet through other technologies.

67
00:04:11,340 --> 00:04:13,830
So here I just returned number three.

68
00:04:13,860 --> 00:04:14,150
OK.

69
00:04:14,160 --> 00:04:20,740
I'm not going to actually create some case statements for that for those kinds of technologies but but

70
00:04:20,880 --> 00:04:25,330
here are creating two case statements for a wife and mobile.

71
00:04:25,410 --> 00:04:26,310
OK.

72
00:04:26,790 --> 00:04:31,970
And here as you can see I have this Else statement that is actually related to this.

73
00:04:32,160 --> 00:04:39,060
If the to this statement and this means that if network info is equal to null and this means that we

74
00:04:39,060 --> 00:04:44,350
are not actually connected to the Internet at all then it's going to return to zero.

75
00:04:44,430 --> 00:04:50,720
So here I can say that return for example number one thousand and this means that the device is actually

76
00:04:51,090 --> 00:04:53,770
not actually connected to the Internet at all.

77
00:04:53,880 --> 00:04:54,370
OK.

78
00:04:54,450 --> 00:05:00,690
So this is how you actually specify that whether your device is actually connected to the Internet or

79
00:05:00,690 --> 00:05:01,210
not.

80
00:05:01,320 --> 00:05:03,310
And what is going to be the type of the Internet.

81
00:05:03,350 --> 00:05:05,840
OK Wi-Fi or type more bite.

82
00:05:05,880 --> 00:05:06,590
So let's go inside.

83
00:05:06,630 --> 00:05:11,830
Our main activity that you will find here unless I try to use this class is network class the Java file.

84
00:05:11,880 --> 00:05:13,650
So now inside is unclear.

85
00:05:13,680 --> 00:05:18,900
Meffert that is inside of these main activity class that's actually going to actually be pasting some

86
00:05:18,900 --> 00:05:23,410
lines of code here and then I'm going to explain to you what's going on here.

87
00:05:23,520 --> 00:05:28,640
So as you can see here these are the lines of code that I actually pasted here.

88
00:05:28,650 --> 00:05:32,270
OK so now I'm going to explain to you what's going on here.

89
00:05:32,490 --> 00:05:41,160
So in line 45 as you can see I actually created a body of type integer right and the name of this variable

90
00:05:41,160 --> 00:05:44,920
is status infl assignment operator.

91
00:05:45,030 --> 00:05:45,830
As you can see here.

92
00:05:45,930 --> 00:05:52,490
So here I called this a class network in Forth I've referred to the name of this class networth info

93
00:05:52,920 --> 00:05:55,970
that gets network status.

94
00:05:55,980 --> 00:06:01,900
So here I am actually calling this static method that is inside of this network info class.

95
00:06:01,930 --> 00:06:07,050
So let's ask you to go inside this networking for the terrified and as you can see here inside this

96
00:06:07,050 --> 00:06:13,010
class that's network info I have the Smurfette which is actually static gets network status and this

97
00:06:13,010 --> 00:06:16,020
method returns a value of that integer.

98
00:06:16,060 --> 00:06:19,040
OK so that's why insight is sweetest statement.

99
00:06:19,050 --> 00:06:24,790
I am actually returning these values if the device is actually connected to the Internet for Wi-Fi then

100
00:06:24,820 --> 00:06:28,290
it does me if it is going to return the value number one then.

101
00:06:28,330 --> 00:06:33,830
Or if the device is actually connected to the Internet flew mobile dentist if is going to return the

102
00:06:33,830 --> 00:06:39,240
value number to zero or if the device is actually connected to the Internet through other technologies

103
00:06:39,540 --> 00:06:42,340
that then it's going to get you to retain the value number is free.

104
00:06:42,480 --> 00:06:43,140
OK.

105
00:06:43,440 --> 00:06:50,070
And if the actually device is not actually connected to the Internet at all then it's going to returned

106
00:06:50,100 --> 00:06:51,800
a value a number one thousand.

107
00:06:52,070 --> 00:06:55,410
OK so let's go back to our main activity that I've offered here.

108
00:06:55,410 --> 00:07:01,640
So this is going to return a value of the integer and this method actually to assets of value of type

109
00:07:01,650 --> 00:07:02,280
context.

110
00:07:02,280 --> 00:07:09,600
So the past is context main activity that this and he had created us some if else statements here.

111
00:07:09,750 --> 00:07:17,630
So here I have this if statement so if status in for if this valuable integer is equal to number 1.

112
00:07:17,670 --> 00:07:21,270
So this means that our device is actually connected to the internet for a wife.

113
00:07:21,300 --> 00:07:21,940
Right.

114
00:07:21,960 --> 00:07:24,320
So here I actually referred to the name of this.

115
00:07:24,360 --> 00:07:26,360
I imagine it's work type here.

116
00:07:26,400 --> 00:07:27,700
I imagine it's worked like that.

117
00:07:27,750 --> 00:07:34,140
Image triable get resources that get triable are that triable that Whyfor Internet.

118
00:07:34,140 --> 00:07:39,610
So here I am referring to the triable folder inside my resources and and here I am actually referring

119
00:07:39,620 --> 00:07:46,830
to the name of this image are that triable that Whyfor Internet as you can see here in my project structure

120
00:07:46,830 --> 00:07:48,310
inside the tribal folder.

121
00:07:48,480 --> 00:07:52,450
I have this mobile internet that PNB and Wi-Fi Internet that PNB OK.

122
00:07:52,500 --> 00:07:53,740
So you have these two images.

123
00:07:53,910 --> 00:07:58,300
In my project and here I am really fairly image to the name of this Wi-Fi Internet here.

124
00:07:58,350 --> 00:08:04,260
As you can see so now here again I am actually creating a toast object in order to let the user know

125
00:08:04,530 --> 00:08:09,710
that the device is actually connected to the Internet for wifely Wi-Fi Internet.

126
00:08:10,050 --> 00:08:15,180
And here I have an AS IF statement so if status info is equal to number zero.

127
00:08:15,420 --> 00:08:19,290
And this means that the device is actually connected from the Internet to the Internet through more

128
00:08:19,280 --> 00:08:19,980
wide.

129
00:08:19,980 --> 00:08:21,650
So again I am doing network time.

130
00:08:21,660 --> 00:08:28,530
That said IMET triable said image triable get resources that get triable are triable that more by Internet.

131
00:08:28,530 --> 00:08:29,190
OK.

132
00:08:29,490 --> 00:08:35,430
And he had created a toast object toast that make takes and this is their first argument this is going

133
00:08:35,430 --> 00:08:36,630
to be the second argument.

134
00:08:36,630 --> 00:08:40,150
Mobile internet and this is the land line shortcut show.

135
00:08:40,650 --> 00:08:45,870
And here I have an else statement and this means that if the device is actually connected to the Internet

136
00:08:46,280 --> 00:08:52,110
of other technologies or that device is not actually connected to the Internet at all then it is going

137
00:08:52,250 --> 00:08:54,420
to execute this or else statement here.

138
00:08:54,420 --> 00:08:57,760
So inside this I am inside this Ellis statement.

139
00:08:57,780 --> 00:09:00,280
I imagine it's for type that said Image resource.

140
00:09:00,330 --> 00:09:01,580
Art that's me pass me.

141
00:09:01,650 --> 00:09:03,720
Map that see Lanter.

142
00:09:04,050 --> 00:09:04,760
OK.

143
00:09:05,070 --> 00:09:10,680
And then in line 55 TOSed that make text the main activity that this and the taste that is going to

144
00:09:10,680 --> 00:09:16,940
be shown to the user is unknown and the land is short and it is going to be shown to the user.

145
00:09:17,070 --> 00:09:17,500
OK.

146
00:09:17,670 --> 00:09:23,550
So this I.S. launcher is actually the image that we have in our project as the actually the image of

147
00:09:23,550 --> 00:09:25,200
the icon of the application.

148
00:09:25,200 --> 00:09:31,260
So as you can see here in my project structure in say displays folder I have this map directory here.

149
00:09:31,410 --> 00:09:36,960
So inside this map directory I have these I.S. lunchers here as you can see with different qualities

150
00:09:37,740 --> 00:09:38,600
as you can see here.

151
00:09:38,700 --> 00:09:39,330
OK.

152
00:09:39,330 --> 00:09:44,670
So I just referred to the name of this image in my main activity class in order to let the user know

153
00:09:44,670 --> 00:09:50,010
that the technology is unknown or the user is not actually connected to the Internet or I can actually

154
00:09:50,010 --> 00:09:56,640
create another else if statement in order to actually see whether that whether the device is actually

155
00:09:56,640 --> 00:09:59,720
connected to the Internet for all other technologies.

156
00:09:59,950 --> 00:10:04,190
So I can actually create an else if statement and check for them.

157
00:10:04,780 --> 00:10:09,240
These are networks that this is actually equal to number three as you can see here.

158
00:10:09,400 --> 00:10:11,450
This status info is equal to number of.

159
00:10:11,560 --> 00:10:17,050
Then I can actually create a toast or actually set on an image to the image for you and let the user

160
00:10:17,050 --> 00:10:20,410
know that the device is actually connected to the Internet.

161
00:10:20,410 --> 00:10:22,570
And it is actually using other technologies.

162
00:10:22,570 --> 00:10:23,310
OK.

163
00:10:23,770 --> 00:10:25,360
So hopefully that makes sense.

164
00:10:25,360 --> 00:10:29,830
And now let's actually run our project and see what happens.

165
00:10:29,830 --> 00:10:34,060
So as you can see here our application is running on this emulator right.

166
00:10:34,060 --> 00:10:37,990
So let's actually click on the spot and let's see what happens.

167
00:10:38,050 --> 00:10:44,530
And now as you can see our application actually crashed and the answer there isn't that this application

168
00:10:44,530 --> 00:10:50,730
is actually crashed is actually inside this manifest here inside this android manifested.

169
00:10:50,760 --> 00:10:53,770
Example here when you actually put some permissions.

170
00:10:53,770 --> 00:10:59,850
So inside this manifest tag as you can see here inside this manifest tag I need to put some permissions.

171
00:10:59,870 --> 00:11:02,340
So here I just need to open a tag.

172
00:11:02,590 --> 00:11:08,620
And then here I just need to type in user's permission and first of all I need to access the wife by

173
00:11:09,430 --> 00:11:16,120
state and that I need to close this permission here and then here I need to actually access the Internet.

174
00:11:16,150 --> 00:11:22,980
So here I need to actually type in users permission and here I just need to type in Internet and then

175
00:11:22,980 --> 00:11:25,120
I need to close this permission this attack.

176
00:11:25,120 --> 00:11:29,870
I need to put this closing tag here or I could actually use self-closing.

177
00:11:29,920 --> 00:11:36,510
So here I could just typing here slash and this and this is a closing tag here as you can see.

178
00:11:36,670 --> 00:11:44,380
And in this way I am actually close in this attack here or I can actually use this one here in this

179
00:11:44,380 --> 00:11:46,300
way I could actually close the stack.

180
00:11:46,330 --> 00:11:47,200
OK.

181
00:11:47,670 --> 00:11:54,280
And now I could actually I need to actually add another permission so I need to typing I need to put

182
00:11:54,280 --> 00:11:59,210
this open in tag here and then I just need to type in user's permission.

183
00:11:59,350 --> 00:12:01,500
And here I need to type pean.

184
00:12:01,600 --> 00:12:03,220
Network.

185
00:12:03,940 --> 00:12:05,840
Network Access Network state.

186
00:12:05,980 --> 00:12:06,700
OK.

187
00:12:06,700 --> 00:12:10,860
So here I just need to close this up Hermitian here is attached here.

188
00:12:10,960 --> 00:12:14,020
So as you can see here I need to put these permissions here.

189
00:12:14,250 --> 00:12:14,840
OK.

190
00:12:15,100 --> 00:12:18,470
And I need to ask the user that you want to actually access this permissions.

191
00:12:18,500 --> 00:12:25,480
OK I need to access these features access by state access this internet and access networks.

192
00:12:25,690 --> 00:12:26,230
OK.

193
00:12:26,470 --> 00:12:29,210
So let's run our project again and see what happens.

194
00:12:29,320 --> 00:12:33,310
So as you can see here our application is running on this emulator here.

195
00:12:33,400 --> 00:12:39,130
So let's actually click on this network status button here and now as you can see it says mobile internet

196
00:12:39,430 --> 00:12:41,330
and we have this image here more wide.

197
00:12:41,440 --> 00:12:41,940
OK.

198
00:12:41,950 --> 00:12:47,620
So this device this emulator is actually connected to the Internet from Mobile not qualify.

199
00:12:47,880 --> 00:12:48,480
OK.

200
00:12:49,300 --> 00:12:55,540
So you can actually do it on this application on your actual device and you can actually see the results

201
00:12:55,540 --> 00:12:56,120
there.

202
00:12:56,380 --> 00:13:02,650
So hopefully that makes sense and I think that's enough for this tutorial so if you have any questions

203
00:13:02,950 --> 00:13:07,620
please post the discussion in the course and then I'll do my best to answer all of your questions.

204
00:13:07,630 --> 00:13:10,900
Thank you very much for watching and I'll see you in the next tutorial.

