1
00:00:00,210 --> 00:00:06,210
Hi everyone in this theater all we're going to go ahead and create another Android application.

2
00:00:06,210 --> 00:00:09,750
So just click on this start in your Android studio project.

3
00:00:09,900 --> 00:00:18,270
And then here for the application name just type in here app 50 free and then click on next and here

4
00:00:18,300 --> 00:00:24,590
choose AP A16 Android 4.1 jellybean for our minimum STK and then click on next.

5
00:00:24,960 --> 00:00:30,660
And then here choose MT activity next and then click on finish.

6
00:00:30,660 --> 00:00:34,400
So as you can see here now our project is actually created.

7
00:00:34,440 --> 00:00:39,950
So let's actually go inside this folder here and then double click and this layout folder.

8
00:00:40,290 --> 00:00:46,470
And then here double click on this activity underlaid mean that examen here and now it's actually designed

9
00:00:46,470 --> 00:00:48,610
to use an interface of our application.

10
00:00:48,780 --> 00:00:54,070
So just selectees hellova that takes you here and then press on delete key on your keyboard.

11
00:00:54,390 --> 00:01:01,350
So now let's actually drag a linearly out vertical as you can see here inside these layouts folder we

12
00:01:01,350 --> 00:01:07,820
have this linearly alphabetical just selected and put it at the center of this relatively held here.

13
00:01:08,340 --> 00:01:13,250
And then let's actually drag an image view into this linearly or Trypticon.

14
00:01:13,380 --> 00:01:19,530
So just select this image view here inside these widgets folder and then drag it into these linearly

15
00:01:19,530 --> 00:01:24,070
and vertical so just put it at the center of this linearly out vertical.

16
00:01:24,270 --> 00:01:29,450
So as you can see here are the gravity of this image view is actually center horizontally.

17
00:01:29,600 --> 00:01:30,000
OK.

18
00:01:30,090 --> 00:01:37,650
So this lay out gravity attributes is going to determine the position of this image view inside its

19
00:01:37,650 --> 00:01:40,580
parent which is this little linearly I swear to god.

20
00:01:40,590 --> 00:01:44,950
So this is gravity here as you can see is actually center horizontal.

21
00:01:44,970 --> 00:01:51,900
So now let's actually assigned a value 200 for the lay out width of this image view here.

22
00:01:51,930 --> 00:01:58,740
So just like this left here inside this property section just assigned a value 200 for the outfit.

23
00:01:59,070 --> 00:02:04,450
And as under-valued 200 for the layout height as you can see here it is 200 ATP.

24
00:02:04,520 --> 00:02:05,130
OK.

25
00:02:05,370 --> 00:02:07,680
Dependent are dependent pixels.

26
00:02:07,680 --> 00:02:10,450
So now as you can see this is our image view.

27
00:02:10,770 --> 00:02:16,590
And now let's actually track some images into our project so as you can see here on my desktop I have

28
00:02:16,590 --> 00:02:17,440
some images.

29
00:02:17,640 --> 00:02:24,280
So I just need to select him and I just need to right click on them and then click on copy 2 items and

30
00:02:24,380 --> 00:02:30,930
in my android studio inside my project structure here I just need to select this triable folder which

31
00:02:30,930 --> 00:02:33,240
is inside this folder here.

32
00:02:33,240 --> 00:02:39,070
So just select this triable for there and right click on it and then click on paste.

33
00:02:39,600 --> 00:02:41,620
So then click on OK.

34
00:02:41,820 --> 00:02:44,050
So as you can see here I have these images here.

35
00:02:44,100 --> 00:02:50,490
Mobile internet at PNB and Voiceprint Internet that P.A. and then let's actually track our Potten into

36
00:02:50,490 --> 00:02:52,530
this linearly out vertical.

37
00:02:52,560 --> 00:02:56,330
So as you can see here inside these widgets folder I have this button here.

38
00:02:56,340 --> 00:02:56,890
OK.

39
00:02:57,030 --> 00:03:01,380
Just select it and put it below this image view here.

40
00:03:01,860 --> 00:03:07,400
And for the lay out which is kind of value match Pallant and double click on it.

41
00:03:07,710 --> 00:03:11,720
And for the text just typing here.

42
00:03:11,820 --> 00:03:12,450
Network

43
00:03:15,900 --> 00:03:17,400
status.

44
00:03:17,750 --> 00:03:30,190
And for the ID just typing here between gets network status OK and then press enter key on your keyboard.

45
00:03:30,490 --> 00:03:34,210
So now the design of our user interface is actually finished.

46
00:03:34,210 --> 00:03:37,300
So let's go back to our main activity over here.

47
00:03:37,420 --> 00:03:40,690
And then let's actually declare some objects.

48
00:03:40,690 --> 00:03:44,660
So the first object that you want to declare here is actually that image view.

49
00:03:45,040 --> 00:03:48,630
So Image view and the name of my image view is going to be I m g.

50
00:03:48,700 --> 00:03:53,980
So let's actually go back to our activity under minute example and W.W. on this imagery as you can see

51
00:03:54,380 --> 00:03:57,230
let's actually assign an ID to this image.

52
00:03:57,250 --> 00:04:07,120
So for the ID just type in here I M G network network type and then press Enter key on your keyboard.

53
00:04:07,140 --> 00:04:10,370
So let's go back to our main activity that double file here.

54
00:04:10,550 --> 00:04:14,570
And for the name of your image you hear just typing here.

55
00:04:14,640 --> 00:04:22,740
I imagine it's for each type and then put a semicolon here at the end of your statement and then it's

56
00:04:22,740 --> 00:04:24,470
actually declared a button object.

57
00:04:24,510 --> 00:04:27,930
So beat button and the name of my object is going to be between.

58
00:04:27,930 --> 00:04:36,790
Get a network status and then put a semicolon at the end of your statement.

59
00:04:37,030 --> 00:04:42,220
So now let's actually go inside and create Meffert in order to actually initialize these objects.

60
00:04:42,220 --> 00:04:45,670
So the first object that I want to initialize is actually IMJ network type.

61
00:04:45,810 --> 00:04:52,650
Assignment operator and then I need to actually trust this object to a image view object find view by

62
00:04:52,660 --> 00:04:55,290
id r that ID.

63
00:04:55,750 --> 00:05:00,290
I m G network type and include a semicolon at the end of your statement.

64
00:05:00,460 --> 00:05:06,550
And and here I need to initialize this BT and get network status object assignment operator and then

65
00:05:06,550 --> 00:05:15,640
here I need to cast this object to a button object find view by ID or that ID that PTEN network status

66
00:05:15,970 --> 00:05:18,510
and then put a semicolon at the end of your statement.

67
00:05:18,520 --> 00:05:21,960
So now lets actually make the spot and listen to the clicks of the user.

68
00:05:21,970 --> 00:05:28,630
So I just need to type in here PTEN and I get network status that set unclick listener.

69
00:05:29,080 --> 00:05:35,950
And then here I need to actually put the context so the context is going to be main activity that this

70
00:05:36,680 --> 00:05:41,740
and and here at the top I need to actually implement the view that unclick less than an interface.

71
00:05:41,740 --> 00:05:47,650
So here I just type in implements view that on click listener.

72
00:05:47,820 --> 00:05:48,400
OK.

73
00:05:48,610 --> 00:05:54,460
And then here inside our class inside our main activity class I just need to type in and click.

74
00:05:54,610 --> 00:06:00,220
So here I am actually all writing the uncloaked method that is actually inside of this like this in

75
00:06:00,220 --> 00:06:00,820
an interface.

76
00:06:00,820 --> 00:06:01,340
OK.

77
00:06:01,570 --> 00:06:07,600
So here whenever the user clicks on this button BT and get and get BT and get networks that is the Smurfette

78
00:06:07,600 --> 00:06:09,450
here is going to be executed.

79
00:06:09,460 --> 00:06:12,820
So lets actually change the name of this argument to view.

80
00:06:13,270 --> 00:06:19,750
And now lets actually create a Java class in our project in order to actually get the network status

81
00:06:20,060 --> 00:06:21,950
OK of our mobile device.

82
00:06:22,090 --> 00:06:27,780
So lets actually click on this package here that is inside of the Java folder or just click on the packet

83
00:06:27,820 --> 00:06:32,670
and then right click on it and the new and then Java class.

84
00:06:32,680 --> 00:06:36,150
So here I just need to select this Java class and click on it.

85
00:06:36,460 --> 00:06:41,290
So for the name just typing here network network info.

86
00:06:41,440 --> 00:06:43,790
So this is the name of my class and it's working for.

87
00:06:43,990 --> 00:06:45,350
And then click on OK.

88
00:06:45,460 --> 00:06:48,020
So as you can see here my class is actually created.

89
00:06:48,130 --> 00:06:53,560
So now I'm going to paste in some lines of code here and then I'm going to explain to you what's going

90
00:06:53,560 --> 00:06:54,410
on here.

91
00:06:54,760 --> 00:06:59,690
So as you can see here these are the lines of code that I actually pasted here.

92
00:06:59,800 --> 00:07:03,010
So when I try to explain to you what's going on here.

93
00:07:03,190 --> 00:07:09,250
So as you can see here I have a method here and the access modifier of this method is public.

94
00:07:09,280 --> 00:07:15,280
This method is actually static so I can actually fair to dismiss it by using the name of this class

95
00:07:15,530 --> 00:07:17,230
dot the name of this method.

96
00:07:17,230 --> 00:07:17,650
OK.

97
00:07:17,710 --> 00:07:21,850
So that's why I put this key word here this is going to be a class if it.

98
00:07:21,870 --> 00:07:22,380
OK.

99
00:07:22,650 --> 00:07:23,510
So static.

100
00:07:23,770 --> 00:07:25,420
And we have this it here.

101
00:07:25,420 --> 00:07:29,340
So this means that this method it is going to return a value of the integer.

102
00:07:29,350 --> 00:07:31,350
So this is the return type OK.

103
00:07:31,630 --> 00:07:33,460
So the return type is integer.

104
00:07:33,460 --> 00:07:39,610
And this this is the name of my Meffert get network status and this method actually accepts an argument

105
00:07:39,670 --> 00:07:42,030
of type context as you can see here.

106
00:07:42,310 --> 00:07:46,260
So now let's actually go inside this method and see what's going on here.

107
00:07:46,360 --> 00:07:52,560
So first of all as you can see I actually created an object of type connectivity manager.

108
00:07:52,840 --> 00:07:54,570
OK connectivity manager.

109
00:07:54,580 --> 00:07:55,870
So what does this mean.

110
00:07:55,930 --> 00:08:01,840
This connectivity manager is actually the class that is defined in Android and here as you can see I

111
00:08:01,840 --> 00:08:07,120
am actually casting this object to a connectivity manager object.

112
00:08:07,450 --> 00:08:13,030
And here I just referred to the name of this context that I receive as an argument from the Smurfit

113
00:08:13,300 --> 00:08:15,770
so context that sets system service.

114
00:08:15,780 --> 00:08:20,250
So here I actually called the Smurfette get system service.

115
00:08:20,290 --> 00:08:26,630
So here I actually created this kind of connectivity manager object in order to get a network in for.

116
00:08:26,650 --> 00:08:31,070
OK so that I can actually sit see that.

117
00:08:31,390 --> 00:08:36,020
What kind of Internet this device is actually uses.

118
00:08:36,100 --> 00:08:39,640
It is actually a type of Wi-Fi or it is actually type Mobot.

119
00:08:39,640 --> 00:08:43,040
So that's why I created this object connectivity manager.

120
00:08:43,330 --> 00:08:49,570
And then I hear context that gets system service so he had to get the system service of connectivity

121
00:08:49,570 --> 00:08:56,920
service OK so that I can actually identify how my how the device is actually connected to the Internet

122
00:08:57,040 --> 00:08:59,490
for wife or for my wife.

123
00:08:59,500 --> 00:09:05,290
So as you can see here get system service and here I referred to the name of this context class as you

124
00:09:05,290 --> 00:09:11,250
can see here this is capital C and then I called this connectivity service here.

125
00:09:11,290 --> 00:09:13,840
This is actually Salt's actually a hold.

126
00:09:13,870 --> 00:09:14,510
They come and.

127
00:09:14,510 --> 00:09:19,090
Q So if you are using your windows machine hold the control key and then click on the connectivity said

128
00:09:19,210 --> 00:09:24,010
service here and now as you can see here I am inside this context that of a file.

129
00:09:24,160 --> 00:09:27,060
And this is actually I think valuable.

130
00:09:27,190 --> 00:09:27,740
OK.

131
00:09:28,000 --> 00:09:29,950
And this is a constant as you can see here.

132
00:09:29,950 --> 00:09:31,210
This is fine on.

133
00:09:31,210 --> 00:09:34,430
And as you can see it holds this value connectivity.

134
00:09:34,710 --> 00:09:43,000
So by actually referring to this variable to this constant as you can see here I can identify that how

135
00:09:43,270 --> 00:09:50,020
the device is actually connected to the Internet and in line 17 as you can see here you referred to

136
00:09:50,020 --> 00:09:51,200
the name of this package.

137
00:09:51,220 --> 00:09:53,290
Android dot net dot net.

138
00:09:53,280 --> 00:09:54,180
14:4.

139
00:09:54,440 --> 00:09:55,030
OK.

140
00:09:55,330 --> 00:09:59,670
I refer to the name of this package and and I called this class and it's well informed.

141
00:09:59,740 --> 00:10:05,110
And then I actually created an object of type network in for assignment operator.

142
00:10:05,290 --> 00:10:11,300
So here I called this connectivity manager that gets active networked inforced.

143
00:10:11,560 --> 00:10:19,360
So by using the sniffer they can actually identify the type of the Internet connection of the device

144
00:10:19,630 --> 00:10:21,850
get at it get active network info.

