1
00:00:00,343 --> 00:00:04,343
♪ (robotic music) ♪

2
00:00:04,871 --> 00:00:07,251
Hi, now that you know 
exactly what Android is,

3
00:00:07,251 --> 00:00:09,641
let's just create 
our first application in Android.

4
00:00:09,641 --> 00:00:13,281
To create that, you will be opening up
your Android Studio

5
00:00:13,281 --> 00:00:15,377
and you will be presented 
with this window.

6
00:00:15,377 --> 00:00:19,147
And once you have downloaded all the SDKs,

7
00:00:19,744 --> 00:00:21,912
then you can go ahead 
and design your first application.

8
00:00:21,912 --> 00:00:25,392
Click on the <i>start a new 
Android Studio Project</i>.

9
00:00:26,858 --> 00:00:29,718
Here you need to give 
the application a name.

10
00:00:29,718 --> 00:00:34,575
Let me just call it <i>MyHelloFirstApp</i>.

11
00:00:37,535 --> 00:00:39,686
And this is your company domain name,

12
00:00:39,686 --> 00:00:42,496
it can be anything you'd like it to be.

13
00:00:42,496 --> 00:00:45,456
In my case, it's <i>com.example.demouser</i>.

14
00:00:46,226 --> 00:00:48,646
Combining this Company name
and Application name,

15
00:00:48,646 --> 00:00:50,496
your package name will be formed.

16
00:00:50,496 --> 00:00:52,186
Make sure this package name is unique

17
00:00:52,186 --> 00:00:56,216
because when you're going 
to upload your APK at the end,

18
00:00:56,216 --> 00:01:01,616
that APK package will be checked out

19
00:01:01,616 --> 00:01:03,146
by your Google Play Store.

20
00:01:03,146 --> 00:01:05,324
If it is not unique, 
at that point in time,

21
00:01:05,324 --> 00:01:08,324
you might want to change 
that package name.

22
00:01:08,324 --> 00:01:13,914
If you try to put this<i>
com.example.demouser</i>,

23
00:01:13,914 --> 00:01:16,660
is has already been taken 
by Google, for example,

24
00:01:16,660 --> 00:01:19,080
you can't upload an application like this.

25
00:01:19,080 --> 00:01:23,966
Let's say you put <i>
com.planet.MyHelloFirstApp</i>

26
00:01:23,966 --> 00:01:27,237
and that domain is also taken 
by somebody else,

27
00:01:27,237 --> 00:01:29,047
then you cannot upload it.

28
00:01:29,047 --> 00:01:30,447
It has to be unique.

29
00:01:31,498 --> 00:01:35,498
Next, this is your project location,
for our example purpose

30
00:01:35,875 --> 00:01:38,225
we are going to use 
this package name only.

31
00:01:39,506 --> 00:01:43,336
This is the project location, 
where our project is going to be saved.

32
00:01:43,913 --> 00:01:47,023
You can change it if you like. 
Click on <i>Next</i>.

33
00:01:47,565 --> 00:01:51,305
Then you have to select minimum
and maximum SDK here.

34
00:01:52,321 --> 00:01:54,511
Maximum by default will be that latest one

35
00:01:54,511 --> 00:01:58,851
that is 25 API 
or if you're using 24, 24 API.

36
00:01:59,173 --> 00:02:02,043
And then there will be a minimum
you will have to select.

37
00:02:02,597 --> 00:02:05,099
I could have gone all the way down to nine

38
00:02:05,099 --> 00:02:08,099
and you can see I will be targeting

39
00:02:08,099 --> 00:02:12,939
approximately 100% of the devices, 
right now, in the market.

40
00:02:12,939 --> 00:02:15,477
The problem here is the more I go down

41
00:02:15,477 --> 00:02:17,297
the more I'm sacrificing the features.

42
00:02:17,297 --> 00:02:19,917
Because the <i>Gingerbread</i> will not contain

43
00:02:19,917 --> 00:02:23,647
all the features which
my Android API 25 contains.

44
00:02:25,258 --> 00:02:27,948
Of course, even if I am selecting 15,

45
00:02:27,948 --> 00:02:29,998
15 will not contain all the features

46
00:02:29,998 --> 00:02:32,466
which my API 25 contains, right?

47
00:02:32,466 --> 00:02:36,221
But till 15, I can get 
the Android Support Library,

48
00:02:36,221 --> 00:02:40,001
that is the external leverage
provided by the Android Framework

49
00:02:40,001 --> 00:02:41,741
and you can get those libraries

50
00:02:41,741 --> 00:02:44,921
to support those features 
up until a version.

51
00:02:44,921 --> 00:02:48,792
I cannot get support libraries below--

52
00:02:48,792 --> 00:02:51,082
all the way down to the 2.3.

53
00:02:51,082 --> 00:02:53,342
So that's why you need 
to make a balance also,

54
00:02:53,342 --> 00:02:56,342
and you can see 
while I'm selecting <i>API 15</i>,

55
00:02:56,342 --> 00:02:59,202
I can still target 97.4% of the devices.

56
00:02:59,202 --> 00:03:00,768
That's a good thing.

57
00:03:01,827 --> 00:03:05,947
Go to <i>Next</i>, then you will see 
all of these templates,

58
00:03:05,947 --> 00:03:08,507
you can select any 
of these templates to start

59
00:03:08,507 --> 00:03:12,133
your Android application development 
as we are starting our very first app

60
00:03:12,133 --> 00:03:14,613
and we are going to start from scratch.

61
00:03:16,033 --> 00:03:18,823
I will click on <i>Empty Activity</i>
and press <i>Next</i>.

62
00:03:19,559 --> 00:03:24,051
Give the name of that activity,
I'm going to call it <i>MainActivity</i> only.

63
00:03:24,051 --> 00:03:25,541
That's it.

64
00:03:26,061 --> 00:03:29,421
You can give any name, whatever you like,

65
00:03:29,421 --> 00:03:34,341
this will ensure that 
you're creating an activity name

66
00:03:34,941 --> 00:03:38,761
that is the Java file, plus the layout 
that is the XML file.

67
00:03:38,761 --> 00:03:42,921
It will create a layout file,
if you don't want that, uncheck this.

68
00:03:42,921 --> 00:03:45,799
But you definitely want 
the UI bar of your activity also,

69
00:03:45,799 --> 00:03:47,819
how, exactly activity
will look like on the screen.

70
00:03:47,819 --> 00:03:48,979
You want that,.

71
00:03:48,979 --> 00:03:51,799
And then there is 
a <i>backward compatibility</i> checked.

72
00:03:53,650 --> 00:03:56,475
Turning this on that means your activity

73
00:03:56,475 --> 00:03:59,475
will be extending <i>AppCompat</i> activity.

74
00:03:59,475 --> 00:04:01,466
If you uncheck this then your activity

75
00:04:01,466 --> 00:04:04,426
will be extending <i>extended activity class</i>.

76
00:04:04,426 --> 00:04:06,886
So <i>backward compatibility</i> is to make sure

77
00:04:06,886 --> 00:04:10,186
that even the previous versions

78
00:04:10,186 --> 00:04:13,920
are able to access the new features

79
00:04:13,920 --> 00:04:16,080
which are there in new versions

80
00:04:16,080 --> 00:04:18,600
with the help of support libraries.

81
00:04:18,600 --> 00:04:19,827
Press on <i>Finish</i>.

82
00:04:24,181 --> 00:04:26,841
Let the <i>Gradle</i> build.<i>
Gradle</i> is a building tool here

83
00:04:26,841 --> 00:04:30,841
which is used by your Android system
to build your application.

84
00:04:33,116 --> 00:04:36,964
Please, wait for <i>Gradle</i>
to build your project first.

85
00:04:36,964 --> 00:04:40,555
If you try to keep on
clicking here and there,

86
00:04:40,555 --> 00:04:42,585
your <i>Gradle</i> might crash.

87
00:04:42,585 --> 00:04:46,195
You need a pretty fast machine 
for <i>Gradle</i> not to crash.

88
00:04:46,926 --> 00:04:49,323
So let the <i>Gradle</i> build, 
once the <i>Gradle</i>--

89
00:04:49,323 --> 00:04:53,051
you'll see down below "indexing is done"
and <i>Gradle</i> is built,

90
00:04:53,051 --> 00:04:56,989
after that, you can see 
this is the Java file

91
00:04:56,989 --> 00:05:01,270
that is <i>MainActivity</i>, 
the Activity in Java file,

92
00:05:01,270 --> 00:05:03,580
and this is the Activity's layout file.

93
00:05:03,580 --> 00:05:04,850
That is the XML file.

94
00:05:04,850 --> 00:05:07,510
This is how your first application 
will look like.

95
00:05:08,483 --> 00:05:12,157
Now before doing anything else,
let me just run this application.

96
00:05:12,157 --> 00:05:14,194
To run this application, first of all,

97
00:05:14,194 --> 00:05:17,194
you need to create a virtual device.

98
00:05:17,194 --> 00:05:19,894
How can you create a virtual device?

99
00:05:19,894 --> 00:05:25,420
There's this icon, AVD manager,
known as "Android Virtual Device".

100
00:05:25,420 --> 00:05:26,500
Click on that.

101
00:05:28,159 --> 00:05:30,459
Ei<i>ther there will be 
a by default</i> virtual device

102
00:05:30,459 --> 00:05:33,489
created for you by Android
or you will be seeing this screen.

103
00:05:33,489 --> 00:05:36,324
You can even delete that <i>Virtual Device</i>
and come to this screen.

104
00:05:36,324 --> 00:05:38,378
Click on this button,

105
00:05:38,378 --> 00:05:41,378
and select one of the resolution device

106
00:05:41,388 --> 00:05:42,798
which you want to work on.

107
00:05:42,798 --> 00:05:47,278
That's a <i>Nexus 5</i>, 
screen resolution 1080x1920.

108
00:05:47,681 --> 00:05:50,511
If you want to work 
with this kind of resolution, go ahead.

109
00:05:50,523 --> 00:05:52,723
Or if you want to work 
with any other resolution

110
00:05:52,723 --> 00:05:55,243
you can select that too.

111
00:05:55,243 --> 00:05:56,613
Press <i>Next</i>.

112
00:05:56,613 --> 00:06:00,597
Then it asks you what should be 
your system image,

113
00:06:00,598 --> 00:06:04,978
which system image you want to run
on your virtual device.

114
00:06:04,990 --> 00:06:08,430
Now, here it will only show you 
the system images

115
00:06:08,430 --> 00:06:10,970
that you downloaded,

116
00:06:10,970 --> 00:06:14,530
at the time of downloading 
from your SDK manager.

117
00:06:15,574 --> 00:06:19,574
In mine, you can see there is 
a 23 and a 25, so I will go with 25.

118
00:06:19,574 --> 00:06:23,464
I'm using <i>x86_64</i>
that too with Google API.

119
00:06:23,464 --> 00:06:26,587
If you don't want to use this Google API,

120
00:06:26,587 --> 00:06:29,957
then you can go with normal <i>x86</i>

121
00:06:29,957 --> 00:06:33,837
but then you must have downloaded 
that system image here.

122
00:06:34,875 --> 00:06:35,915
Other images.

123
00:06:36,435 --> 00:06:42,245
Any ARM or image if you want 
to work with that too.

124
00:06:42,269 --> 00:06:45,122
but I wouldn't recommend the ARM
as they are very slow.

125
00:06:45,122 --> 00:06:48,172
I'd recommend--
I'm using the latest one,

126
00:06:48,172 --> 00:06:50,439
To Google API, press <i>Next</i>.

127
00:06:50,439 --> 00:06:55,049
You can give the name 
of your device or virtual device

128
00:06:55,049 --> 00:07:00,941
anything you want, 
let's say <i>Black_Knight_01</i>

129
00:07:02,682 --> 00:07:04,062
and press <i>Finish</i>.

130
00:07:06,914 --> 00:07:09,579
Here you see my device is ready,

131
00:07:09,579 --> 00:07:12,579
all I have to do is press the <i>Play</i> button.

132
00:07:12,579 --> 00:07:15,817
Launch button 
and it will launch the emulator.

133
00:07:15,817 --> 00:07:19,467
Wait some seconds and you can see

134
00:07:19,467 --> 00:07:22,467
the emulator will be 
up and running in a bit.

135
00:07:22,924 --> 00:07:26,924
<i>x86</i> emulators are way faster 
as compared to your ARM.

136
00:07:27,529 --> 00:07:31,499
If this would have been an ARM machine,

137
00:07:31,499 --> 00:07:34,499
it would've taken a long time to run.

138
00:07:35,278 --> 00:07:40,424
This won't take hardly a minute to turn on

139
00:07:40,424 --> 00:07:45,104
and I would recommend 
once your emulator is on,

140
00:07:45,104 --> 00:07:48,024
whenever you're developing,
do not close your emulator.

141
00:07:49,514 --> 00:07:53,584
Unless you are done for the day
or done with the development

142
00:07:54,688 --> 00:07:55,958
for the day, why ?

143
00:07:55,958 --> 00:07:59,854
Because every time you close 
your emulator and run it again

144
00:07:59,854 --> 00:08:04,941
it will take the same time 
to launch the emulator again and again.

145
00:08:04,941 --> 00:08:08,341
So what you can do here
is just run it once

146
00:08:08,341 --> 00:08:11,871
and then after that, 
keep on running your application

147
00:08:11,871 --> 00:08:13,601
from your Android Studio

148
00:08:13,601 --> 00:08:16,071
and they will directly go 
on your emulator.

149
00:08:16,071 --> 00:08:20,071
So your emulator doesn't have to restart
or get the resources again.

150
00:08:20,475 --> 00:08:24,065
How will you do that?
As you can see, my emulator is running,

151
00:08:24,459 --> 00:08:27,049
What I would do to run my application

152
00:08:27,049 --> 00:08:30,369
is here, you can see a <i>Play</i> button
launch button, or run button.

153
00:08:30,369 --> 00:08:31,841
Just click on that.

154
00:08:31,841 --> 00:08:36,051
My Android Studio automatically detected 
that there is a device

155
00:08:36,052 --> 00:08:39,047
connected to me, 
that's called <i>Black_Knight</i>.

156
00:08:39,047 --> 00:08:40,467
Press on OK.

157
00:08:40,467 --> 00:08:46,902
And this application will run 
on my Android device.

158
00:08:46,902 --> 00:08:49,812
Just wait for it, <i>
Gradle</i> will start building.

159
00:08:49,822 --> 00:08:51,462
If there is any error or something,

160
00:08:51,462 --> 00:08:54,712
that also will be detected 
at this point in time.

161
00:09:05,500 --> 00:09:06,640
There we go.

162
00:09:06,640 --> 00:09:09,666
So this is my very first app,
which I have created

163
00:09:09,666 --> 00:09:11,195
from the Android App Studio.

164
00:09:11,195 --> 00:09:15,285
Even if you close your app now,
you go to your apps,

165
00:09:15,285 --> 00:09:17,255
you can see your app here.

166
00:09:17,255 --> 00:09:20,491
You click on this, so it's just behaving
like any other app.

167
00:09:21,038 --> 00:09:24,178
Now before moving any further in Android,

168
00:09:24,178 --> 00:09:29,476
let's just learn a little bit 
about your Android Studio ID, etc.

169
00:09:29,476 --> 00:09:33,833
The left bar is known as project panel, 
we will come to that.

170
00:09:33,833 --> 00:09:36,223
This middle area is known as code area,

171
00:09:36,223 --> 00:09:39,931
or you can create your layout also here
by dragging and dropping.

172
00:09:39,931 --> 00:09:41,776
The middle part is known as your console.

173
00:09:41,776 --> 00:09:45,471
This is where you will be seeing
what is going on with your Android.

174
00:09:45,471 --> 00:09:51,041
I just ran an application here, 
in my Android Virtual Device.

175
00:09:51,041 --> 00:09:55,211
So it gave me what was going on,
this was the run mode,

176
00:09:55,211 --> 00:09:58,155
what was going on 
with my application in run mode.

177
00:09:58,155 --> 00:10:01,723
But you can go to your Android monitor,
also you will see a <i>logcat</i>.

178
00:10:01,723 --> 00:10:03,934
<i>Logcat</i> will be your friend

179
00:10:03,934 --> 00:10:05,864
throughout your Android 
application development

180
00:10:05,864 --> 00:10:09,624
because it tells you what is going on
in your Android Virtual Device.

181
00:10:10,235 --> 00:10:14,186
Okay, so now you can see here,

182
00:10:14,186 --> 00:10:16,396
this part here is known as project panel,

183
00:10:16,396 --> 00:10:21,442
in this, what you are seeing
is the Android Project Data Key.

184
00:10:21,442 --> 00:10:23,729
We'll talk about other project data key

185
00:10:23,729 --> 00:10:25,609
but when we talk about 
Android Project Data Key,

186
00:10:25,609 --> 00:10:28,149
you will see your project 
is divided in two parts,

187
00:10:28,149 --> 00:10:29,539
one is your app folder,

188
00:10:29,539 --> 00:10:31,769
and the other one 
is your <i>Gradle script folder</i>.

189
00:10:33,373 --> 00:10:36,983
Let's just talk about <i>
Gradle's script folder</i> first.

190
00:10:36,983 --> 00:10:40,891
When we open up our <i>Gradle</i> script,
you will see that in <i>Gradle</i>

191
00:10:40,891 --> 00:10:42,672
there are mainly three types 
of <i>Gradle</i> file,

192
00:10:42,672 --> 00:10:46,022
one is called <i>ProjectMyHello.Gradle</i>

193
00:10:46,022 --> 00:10:47,952
which will contain nothing 
but the information

194
00:10:47,952 --> 00:10:50,248
about my <i>Gradle</i> version itself
as you can see

195
00:10:50,248 --> 00:10:52,568
which <i>Gradle</i> I'm using 
right now is <i>Gradle 2.2.2</i>

196
00:10:52,568 --> 00:10:56,328
and include all the repositories
in this project.

197
00:10:56,873 --> 00:10:59,563
Second <i>Gradle file</i> which we will be seeing

198
00:10:59,563 --> 00:11:00,844
is module level <i>Gradle file</i>.

199
00:11:00,844 --> 00:11:04,207
As I only have the mobile module here
so there is only one.

200
00:11:04,207 --> 00:11:07,050
If there would have been 
an Android <i>wear</i>

201
00:11:07,050 --> 00:11:09,590
then there would be a wear also.

202
00:11:09,590 --> 00:11:12,780
If there would be TV, then 
there would be a TV module file also.

203
00:11:12,780 --> 00:11:14,980
So there is only one, 
what exactly it contains

204
00:11:14,980 --> 00:11:17,770
it contains the information 
of all the module itself.

205
00:11:17,770 --> 00:11:22,240
What is the minimum version 
of SDK I'm going to use,

206
00:11:22,240 --> 00:11:25,445
what is the target version for this SDK,

207
00:11:25,445 --> 00:11:28,055
what is the application ID,

208
00:11:28,055 --> 00:11:31,675
the compilation SDK version,
so all that information

209
00:11:31,675 --> 00:11:34,795
will be included 
in this module-level <i>Gradle</i>,

210
00:11:37,948 --> 00:11:41,578
Even the dependencies you want to add
that is libraries and all--

211
00:11:41,578 --> 00:11:43,838
that will also be added in this.

212
00:11:43,838 --> 00:11:46,818
As you can see there are this many
libraries as of right now.

213
00:11:46,818 --> 00:11:50,865
I'm using the <i>Espresso libraries com</i>,

214
00:11:50,865 --> 00:11:52,365
and the <i>com support</i>,

215
00:11:52,365 --> 00:11:55,044
there is app compact support 
libraries also,

216
00:11:55,044 --> 00:11:58,354
I'm using <i>JUnit</i> library also.

217
00:11:59,184 --> 00:12:01,534
If you want to add any external leverage

218
00:12:01,534 --> 00:12:04,164
that also will be adding 
inside dependencies on it .

219
00:12:04,164 --> 00:12:07,804
So that's what the use 
of the module <i>build Gradle file</i>

220
00:12:07,804 --> 00:12:09,709
it [inaudible]

221
00:12:09,709 --> 00:12:12,229
and gives you the information 
about that particular modules.

222
00:12:12,229 --> 00:12:15,692
Next <i>settings.gradle file</i>,

223
00:12:15,692 --> 00:12:18,692
it's again one file per application.

224
00:12:18,692 --> 00:12:22,572
It tells the compiler which module

225
00:12:22,572 --> 00:12:25,762
has to part into the compilation

226
00:12:25,762 --> 00:12:26,972
at any particular time.

227
00:12:26,972 --> 00:12:28,872
For example, if you have 
a better application

228
00:12:28,872 --> 00:12:32,012
designed also 
for your mobile, TV, and wear,

229
00:12:32,012 --> 00:12:37,477
and your TV, and wear 
are still not complete

230
00:12:37,477 --> 00:12:40,477
for the production level.

231
00:12:40,486 --> 00:12:44,849
Then, when your mobile app 
for <i>wear</i> is complete

232
00:12:44,849 --> 00:12:48,409
then you can include the module
of mobile here only.

233
00:12:48,910 --> 00:12:50,790
Like this, mobile.

234
00:12:50,790 --> 00:12:53,796
Then the name of the <i>Gradle file</i>,

235
00:12:53,796 --> 00:12:56,576
like, right now, it's <i>app</i> here, 
it will be mobile.

236
00:12:56,576 --> 00:13:00,576
And if there is a <i>wear</i> also,
then we will be putting <i>wear</i> too.

237
00:13:04,246 --> 00:13:06,234
Like this: <i>wear</i>.

238
00:13:06,234 --> 00:13:09,984
If there would be a <i>wear</i>
that's the condition,

239
00:13:09,984 --> 00:13:12,624
that there is a <i>wear</i> module too.

240
00:13:13,404 --> 00:13:17,224
Okay, so as of right now, 
there is no <i>wear</i>,

241
00:13:17,224 --> 00:13:21,497
so it's only just one,
that's why this <i>setting-gradle</i> file

242
00:13:21,497 --> 00:13:22,747
contains only app

243
00:13:22,747 --> 00:13:24,637
because that's the only <i>Gradle file</i>

244
00:13:24,637 --> 00:13:27,997
you're going to compile 
whenever you're going to run it.

245
00:13:29,008 --> 00:13:31,368
Okay great, so that was <i>Gradle scripts</i>.

246
00:13:32,630 --> 00:13:34,630
Now let's talk about <i>app bar</i>,

247
00:13:34,630 --> 00:13:40,580
in the <i>app bar</i> you will see 
mainly three folders.

248
00:13:40,580 --> 00:13:43,440
First is your manifest project.

249
00:13:43,440 --> 00:13:46,390
Inside this you will find 
a file <i>android manifest.xml</i>,

250
00:13:46,390 --> 00:13:48,910
this is the file
which comes in contact

251
00:13:48,910 --> 00:13:51,320
with your Android device 
for the very first time

252
00:13:51,320 --> 00:13:52,877
when you install your application.

253
00:13:52,877 --> 00:13:55,167
So when this application 
is getting installed

254
00:13:55,167 --> 00:13:57,357
in any emulator or device,

255
00:13:57,357 --> 00:13:59,732
this is the file that will come in contact

256
00:13:59,732 --> 00:14:01,852
with your Android device 
for the very first time.

257
00:14:01,852 --> 00:14:03,942
What exactly it contains,
it contains the information

258
00:14:03,942 --> 00:14:07,322
about the application itself, 
like the package name,

259
00:14:07,322 --> 00:14:09,942
what's is going to be my package name,

260
00:14:09,942 --> 00:14:14,372
the application's information
like how many screens

261
00:14:14,372 --> 00:14:16,512
or how many activities it'll contain.

262
00:14:16,512 --> 00:14:19,712
If there are more screens, 
then you have to register them here,

263
00:14:19,712 --> 00:14:22,113
only, again if there is another activity,

264
00:14:22,113 --> 00:14:23,873
there will be another activity tag.

265
00:14:23,873 --> 00:14:26,943
Or if there is more services 
then there will be more services tags.

266
00:14:27,836 --> 00:14:31,756
And it will also include the permission,
let's say your application

267
00:14:31,756 --> 00:14:35,046
is going to contain any permission
like internet permission,

268
00:14:35,046 --> 00:14:38,566
or access netbook permission
or GPS permission.

269
00:14:38,566 --> 00:14:42,056
You need to declare those permissions
here inside this manifest file only.

270
00:14:42,056 --> 00:14:44,451
Let's say, I want to include 
the internet permission

271
00:14:44,451 --> 00:14:47,571
I will use this permission, internet,
and there you go.

272
00:14:47,571 --> 00:14:50,200
So this is how your permission 
gets added also.

273
00:14:52,851 --> 00:14:54,911
So that was Android manifest.

274
00:14:54,911 --> 00:14:59,371
In the manifest file you can see 
there are many attributes,

275
00:15:00,091 --> 00:15:02,853
like <i>AllowBackup</i> will make sure

276
00:15:02,853 --> 00:15:08,383
that your application
is compatible for backing up.

277
00:15:08,724 --> 00:15:12,612
And icon attribute here 
is getting the icon

278
00:15:12,612 --> 00:15:15,612
from <i>@mipmap/ic_launcher</i>.

279
00:15:15,612 --> 00:15:18,902
I will talk about this <i>@mipmap</i> in a bit,

280
00:15:18,902 --> 00:15:23,212
but know that this here 
is getting the icon...

281
00:15:23,212 --> 00:15:27,842
Or this label attribute also 
is getting the text

282
00:15:27,842 --> 00:15:29,692
from your resource folder.

283
00:15:29,692 --> 00:15:31,912
We'll talk about how it's getting there.

284
00:15:31,912 --> 00:15:34,636
<i>SupportRTL</i> is again right to left,

285
00:15:34,636 --> 00:15:38,236
there are language which go 
from right to left

286
00:15:38,236 --> 00:15:41,786
so this application
will support RTL language too.

287
00:15:41,786 --> 00:15:44,826
And <i>theme</i>, I'm getting this style 
from resource folder

288
00:15:44,826 --> 00:15:49,496
we'll talk about that also, but know
these attributes are setting...

289
00:15:49,496 --> 00:15:51,726
This one is setting the icon 
to my application

290
00:15:51,726 --> 00:15:53,984
this one is setting the name 
or label to my application

291
00:15:53,984 --> 00:15:57,034
and this one is setting the style 
to my application.

292
00:15:57,874 --> 00:16:00,574
Now let's just go to our Java folder.

293
00:16:00,574 --> 00:16:03,694
When you open up your Java folder
you will find three package,

294
00:16:03,694 --> 00:16:06,284
First package is know 
as development package.

295
00:16:06,284 --> 00:16:08,864
Second package is known 
as Android test package

296
00:16:08,864 --> 00:16:10,239
or instrumented test package.

297
00:16:10,239 --> 00:16:12,475
Third package is known 
as unit testing package.

298
00:16:12,475 --> 00:16:16,206
The first development package

299
00:16:16,206 --> 00:16:19,206
you will put all the code 
for your application development.

300
00:16:19,206 --> 00:16:21,512
This is the package which 
you'll be dealing a lot

301
00:16:21,512 --> 00:16:24,282
when you're doing 
the Android application development.

302
00:16:24,282 --> 00:16:26,376
All your activities, services, broadcasts,

303
00:16:26,376 --> 00:16:28,666
content providers, database classes,

304
00:16:28,666 --> 00:16:32,586
all those classes will be kept inside
this development package only.

305
00:16:32,586 --> 00:16:35,276
As you can see there is 
only one activity right now,

306
00:16:35,276 --> 00:16:37,184
that's <i>MainActivity</i>, if you open up,

307
00:16:37,184 --> 00:16:39,474
this is how your <i>MainActivity</i> looks like.

308
00:16:41,347 --> 00:16:43,911
Inside your <i>MainActivity</i>, 
you can see that--

309
00:16:43,911 --> 00:16:47,841
activity is nothing but a class
which is extending <i>AppCompatActivity</i>

310
00:16:47,841 --> 00:16:51,681
and this <i>AppCompatActivity</i>
is being inherited from

311
00:16:51,681 --> 00:16:54,841
or is taken from
your Android support library.

312
00:16:55,436 --> 00:16:58,380
As you can see, 
AppCompatLibrary is important

313
00:16:58,380 --> 00:17:00,710
for your <i>android.support.v7. app</i>.

314
00:17:00,710 --> 00:17:04,760
Now if I would have done activity also,

315
00:17:05,662 --> 00:17:08,922
then, also syntactically, 
there would be no problem

316
00:17:08,922 --> 00:17:12,414
because ultimately, 
this is activity only, right ?

317
00:17:16,581 --> 00:17:18,423
I'm designing for the latest version

318
00:17:18,423 --> 00:17:21,423
then the features like material design

319
00:17:21,423 --> 00:17:23,682
all the new features, 
will not be supported

320
00:17:23,682 --> 00:17:26,522
by the previous version
if they are not included there.

321
00:17:26,522 --> 00:17:32,302
So that's the reason I want to do
the <i>AppCompatActivity</i>.

322
00:17:33,574 --> 00:17:37,154
Inside your activity, you can see 
there's a method I'm using,

323
00:17:37,154 --> 00:17:39,004
an overrided method called <i>OnCreate</i>,

324
00:17:39,004 --> 00:17:40,774
so that <i>OnCreate</i> method is already defined

325
00:17:40,774 --> 00:17:43,354
inside <i>AppCompatActivity</i>
and I'm just overriding it.

326
00:17:43,354 --> 00:17:46,618
And inside this, there's 
the very first statement I'm doing

327
00:17:46,618 --> 00:17:48,728
which is <i>super.OnCreate</i>.

328
00:17:48,728 --> 00:17:53,218
<i>Super.OnCreate</i> will make sure 
that before I do anything,

329
00:17:53,218 --> 00:17:56,019
before I do any customization 
in this particular method

330
00:17:56,019 --> 00:17:58,189
I want to use all the functionalities

331
00:17:58,189 --> 00:17:59,798
which was there in my parent activity.

332
00:17:59,798 --> 00:18:04,560
I don't want to temper 
with the functionality

333
00:18:04,560 --> 00:18:08,227
which was provided to me

334
00:18:08,227 --> 00:18:11,927
by my Activity class, 
the <i>OnCreate</i> functionality

335
00:18:11,927 --> 00:18:14,497
which was provided to me 
by Activity class.

336
00:18:15,084 --> 00:18:16,234
I want that.

337
00:18:16,234 --> 00:18:20,415
Plus if I want any 
of my own functionality

338
00:18:20,415 --> 00:18:23,705
that I would be including
after including this statement.

339
00:18:24,834 --> 00:18:27,624
Once I include this, 
then I'm including my own statement

340
00:18:27,624 --> 00:18:29,134
that is <i>SetContentView</i>.

341
00:18:29,134 --> 00:18:34,314
I'm providing 
a particular view to my activity

342
00:18:34,314 --> 00:18:37,714
and that I'm also doing 
with <i>R.layout.activity_main</i>.

343
00:18:37,714 --> 00:18:41,047
Just for now, understand that 
I'm attaching my layout file here.

344
00:18:41,047 --> 00:18:44,007
I'm attaching this layout file
as you can see, <i>Activity_Main</i>,

345
00:18:44,007 --> 00:18:45,097
<i>Activity_Main</i>.

346
00:18:45,097 --> 00:18:49,222
I will discuss into more detail in a bit

347
00:18:49,222 --> 00:18:51,332
on how exactly it's getting attached

348
00:18:51,332 --> 00:18:53,643
but you can see <i>activity_main</i> is the file

349
00:18:53,643 --> 00:18:57,833
which is getting attached 
to this particular <i>Main Activity</i> here now.

350
00:18:57,833 --> 00:19:00,766
So that was the development package

351
00:19:00,766 --> 00:19:03,614
and that was the <i>MainActivity</i> file.

352
00:19:03,614 --> 00:19:06,884
In other packages like Android test,

353
00:19:06,884 --> 00:19:11,674
you will see the files 
which are used for UI testing

354
00:19:11,674 --> 00:19:15,972
here all the UI testing class 
will be put inside this--

355
00:19:15,972 --> 00:19:18,602
All the <i>JUnit</i> classes testing,

356
00:19:18,602 --> 00:19:20,612
all the classes for <i>JUnit</i> will be put.

357
00:19:20,981 --> 00:19:22,852
So that was the Java folder.

358
00:19:22,852 --> 00:19:26,332
So the Java folder will 
specifically contain all your coding bar.

359
00:19:26,332 --> 00:19:27,942
Now let's just come to <i>res folder</i>.

360
00:19:27,942 --> 00:19:30,248
Now, <i>res folder</i> is a very important folder

361
00:19:30,248 --> 00:19:32,768
in your Android application development

362
00:19:32,768 --> 00:19:35,858
because Android application development
is not just about Java,

363
00:19:35,858 --> 00:19:40,188
it includes your resources 
and they can be images.

364
00:19:40,188 --> 00:19:45,457
Resources can be layout files, 
XML files, any <i>values resources</i>

365
00:19:45,457 --> 00:19:48,688
that you are providing [hard-coded].

366
00:19:48,688 --> 00:19:51,784
So let's talk about them in more detail.

367
00:19:51,784 --> 00:19:55,834
There will be a <i>res folder</i>
and inside that <i>res folder</i>

368
00:19:55,834 --> 00:19:58,344
there will be some 
dedicated folders like <i>drawable</i>.

369
00:19:58,344 --> 00:20:03,024
<i>Drawable</i> is a folder which will be used
to include the images.

370
00:20:04,797 --> 00:20:06,317
Generally the drawable--

371
00:20:06,317 --> 00:20:09,905
Each and every folder you're gonna design
inside your <i>res folder</i>

372
00:20:09,905 --> 00:20:11,605
will have a specific purpose.

373
00:20:11,605 --> 00:20:14,254
So the drawable here 
is used for your images

374
00:20:14,254 --> 00:20:17,254
or if you have any animations, selectors.

375
00:20:17,254 --> 00:20:19,841
For those kind of things 
you will be using the <i>drawable</i>.

376
00:20:19,841 --> 00:20:22,797
You will be seeing more of it 
in your folder's sessions

377
00:20:22,797 --> 00:20:27,277
what exactly this <i>drawable</i> folder
can be used more for.

378
00:20:27,277 --> 00:20:30,150
For now, understand that all the images

379
00:20:30,150 --> 00:20:32,540
and animation parts you'll put here.

380
00:20:32,540 --> 00:20:35,452
Next is your <i>layout folder</i>.

381
00:20:35,452 --> 00:20:38,246
<i>Layout folder</i> is a folder 
where you will provide all the layout

382
00:20:38,246 --> 00:20:39,886
for your activity.

383
00:20:39,886 --> 00:20:44,329
All the UI part, any layout you want 
to show to your screen

384
00:20:44,329 --> 00:20:46,829
this is the folder 
where you want to design.

385
00:20:46,829 --> 00:20:50,829
So that file which you just saw,
this is where it resides.

386
00:20:51,715 --> 00:20:55,055
<i>Activity_Main.xml</i>,

387
00:20:55,055 --> 00:20:57,691
any XML file you're seeing, 
any layout file you're seeing,

388
00:20:57,691 --> 00:20:59,981
they are in your <i>layout folder</i>.

389
00:20:59,981 --> 00:21:05,679
You can see that this layout here
is the drag and drop screen.

390
00:21:05,679 --> 00:21:10,149
That is called layout, 
there you can drag any button right now,

391
00:21:10,149 --> 00:21:12,609
and place it where you want.

392
00:21:13,358 --> 00:21:17,332
This is the Drag & Drop bar,
when you click on the text tab here

393
00:21:17,332 --> 00:21:20,522
you will be able to see 
the coding part, and the XML part also.

394
00:21:20,522 --> 00:21:22,474
We will discuss about the coding part

395
00:21:22,474 --> 00:21:26,074
and how exactly you can deal 
with these XML parts

396
00:21:26,074 --> 00:21:27,732
for the session.

397
00:21:27,732 --> 00:21:30,192
But for now know that :

398
00:21:30,192 --> 00:21:33,202
in layout folder, 
all the layout file exists

399
00:21:33,202 --> 00:21:37,642
and you can edit the layout 
of these XML file

400
00:21:37,642 --> 00:21:39,782
with the app <i>Layout Editor</i>.

401
00:21:40,249 --> 00:21:41,789
Next is your <i>mipmap</i>.

402
00:21:41,789 --> 00:21:44,789
<i>Mipmap</i> is a folder which is, again, 
used for your images only

403
00:21:44,789 --> 00:21:46,649
but here you can put

404
00:21:46,656 --> 00:21:51,136
the different screen resolution 
images together.

405
00:21:53,723 --> 00:21:57,703
As you can see, the image here 
is known as <i>ic_launcher.png</i>.

406
00:21:57,723 --> 00:22:01,458
Each and every image 
is named the same here,

407
00:22:01,458 --> 00:22:03,838
like <i>ic_launcher.png...</i>

408
00:22:03,838 --> 00:22:06,958
but you can see the difference 
is the resolution.

409
00:22:06,958 --> 00:22:08,741
There will be images which will be--

410
00:22:08,741 --> 00:22:11,274
This image here is high pixel image,

411
00:22:11,274 --> 00:22:13,424
then there is extra high pixel image,

412
00:22:13,424 --> 00:22:17,095
then there is extra, extra high pixel image,
so the resolution changes.

413
00:22:17,095 --> 00:22:19,537
If you have an image 
of a different resolution,

414
00:22:19,537 --> 00:22:22,537
you will put it in the <i>mipmap</i>

415
00:22:22,537 --> 00:22:24,597
by putting the same name.

416
00:22:25,255 --> 00:22:27,205
If my image name is logo

417
00:22:27,205 --> 00:22:29,095
and I have five different 
resolutions of logo

418
00:22:29,095 --> 00:22:33,085
I will put logo only 
but the resolution will be different.

419
00:22:33,085 --> 00:22:36,815
Like one maybe 42x42, other maybe 72x72

420
00:22:36,815 --> 00:22:40,945
and other one, maybe,
extra high 128x128.

421
00:22:41,492 --> 00:22:44,752
So automatically, it will create a folder

422
00:22:44,752 --> 00:22:49,832
which will define my high density
pixel image differently,

423
00:22:49,837 --> 00:22:52,287
and medium density pixel differently,

424
00:22:52,287 --> 00:22:54,727
and extra high density 
pixel image differently.

425
00:22:54,727 --> 00:22:56,567
So what are the use of it?

426
00:22:56,567 --> 00:22:59,320
If you run your application on any device

427
00:22:59,320 --> 00:23:01,750
which uses extra high density pixel,

428
00:23:01,750 --> 00:23:04,744
you don't have to specify 
or put in the code

429
00:23:04,744 --> 00:23:06,884
that use this image.

430
00:23:06,884 --> 00:23:08,804
It will automatically adjust that,

431
00:23:08,804 --> 00:23:11,984
"okay this is my extra high 
density pixel device".

432
00:23:11,984 --> 00:23:14,194
It will automatically 
pick this image only.

433
00:23:14,526 --> 00:23:16,036
That was <i>mipmap</i>.

434
00:23:17,087 --> 00:23:20,303
Now let's talk about values,
now values is a folder

435
00:23:20,303 --> 00:23:23,133
where you generally put all 
your other resource

436
00:23:23,133 --> 00:23:25,763
which you want to put

437
00:23:25,763 --> 00:23:28,473
or show to the users, like colors.

438
00:23:30,971 --> 00:23:33,311
<i>Values</i> is the folder where you want

439
00:23:33,311 --> 00:23:35,981
to define your different resources,

440
00:23:35,981 --> 00:23:37,741
to make the localization.

441
00:23:37,741 --> 00:23:41,151
So you don't have to define 
those resources again, and again.

442
00:23:41,547 --> 00:23:45,463
It may be any string value,
or any title, or any color also.

443
00:23:45,463 --> 00:23:49,843
As you can see, I defined 
a color <i>file.xml</i> separately

444
00:23:49,843 --> 00:23:52,843
and then defined the color tag.

445
00:23:53,445 --> 00:23:57,665
Remember that any resource 
you want to define,

446
00:23:57,665 --> 00:24:00,244
you have to use the resource tag first.

447
00:24:00,244 --> 00:24:03,294
So now this will be a resource,
this color will be a resource

448
00:24:03,294 --> 00:24:06,725
and the name of the color by which 
I'm going to access it anywhere,

449
00:24:06,725 --> 00:24:09,105
is now <i>ColorPrimary</i>.

450
00:24:10,295 --> 00:24:15,215
The use of this will define the resources,

451
00:24:15,215 --> 00:24:17,725
let's say, this is the color right now.

452
00:24:17,725 --> 00:24:22,644
As you can see, the color is 3F51B5.

453
00:24:22,644 --> 00:24:25,427
I don't have to remember 
this color code

454
00:24:25,427 --> 00:24:27,167
or hashcode again and again.

455
00:24:27,167 --> 00:24:31,521
And I can directly use this <i>ColorPrimary</i>
wherever I want to use it.

456
00:24:31,521 --> 00:24:34,121
In a bit we are going to see 
how exactly we can use it.

457
00:24:35,252 --> 00:24:38,423
In the second uses, 
let's say tomorrow your boss says

458
00:24:38,423 --> 00:24:40,903
"I want to change this color".

459
00:24:40,903 --> 00:24:44,747
Instead of <i>ColorPrimary</i>,

460
00:24:44,750 --> 00:24:47,100
you define one more color here,

461
00:24:47,997 --> 00:24:51,977
and that color is <i>Title_Color</i>,
let's call it color.

462
00:24:54,766 --> 00:24:58,136
You define a color called 99ccc--

463
00:24:58,797 --> 00:25:00,837
So, 99cc00.

464
00:25:00,837 --> 00:25:02,509
Okay so this is my <i>title color</i>.

465
00:25:02,509 --> 00:25:06,039
Let's say tomorrow your boss say, 
"we're going to change our title color".

466
00:25:06,039 --> 00:25:09,374
So you don't have to go
to each and every place

467
00:25:09,374 --> 00:25:11,644
where you had used this hashcode.

468
00:25:11,644 --> 00:25:13,575
If you would have done hard-coded here,

469
00:25:13,575 --> 00:25:16,015
you'd have to change the hashcode 
in each and every place.

470
00:25:16,015 --> 00:25:20,055
Here you are just going 
to change the color here

471
00:25:20,055 --> 00:25:22,913
and wherever you've used this name there,

472
00:25:22,913 --> 00:25:25,743
all those places 
will be receiving the changes.

473
00:25:25,743 --> 00:25:28,843
So that's the beauty of defining 
the resources here.

474
00:25:29,431 --> 00:25:32,561
So in this way I have 
to find resource colors

475
00:25:32,561 --> 00:25:35,991
only here you can see <i>ColorPrimary</i>

476
00:25:35,991 --> 00:25:38,541
<i>ColorDark</i>, <i>ColorAccent</i>
and <i>ColorTitle</i>, right ?

477
00:25:39,683 --> 00:25:43,453
One more thing I want to point out here,
anything you put in your resource

478
00:25:43,453 --> 00:25:46,376
even a image, even a layout file, 
even all these color

479
00:25:46,376 --> 00:25:49,807
which I'm putting here right now,
anything you put in your <i>res folder</i>,

480
00:25:49,807 --> 00:25:54,587
they get a registry inside a file
named as <i>Android Java file</i>.

481
00:25:54,587 --> 00:25:57,167
<i>Android Java file</i> is 
a system generated file

482
00:25:57,167 --> 00:26:02,107
which is being provided to you
by your Android system itself,

483
00:26:02,107 --> 00:26:05,957
or the Android application itself,
so you don't have to create it

484
00:26:05,957 --> 00:26:08,547
but whatever you do inside the <i>res folder</i>

485
00:26:08,556 --> 00:26:11,796
that will get entry inside 
the hard-coded Java file.

486
00:26:11,796 --> 00:26:14,626
As of right now, the color 
which I have just defined,

487
00:26:14,626 --> 00:26:19,513
the whole entry plus the <i>ActivityMain.xml</i>
should also have entry

488
00:26:19,513 --> 00:26:22,103
and all these <i>mipmap</i>
should also have a entry.

489
00:26:22,954 --> 00:26:24,934
Let's just check that out.

490
00:26:24,948 --> 00:26:28,468
You won't be seeing <i>R.java file</i>
inside your Android data key.

491
00:26:28,468 --> 00:26:31,718
To see that, you'll need to change
the data key to package.

492
00:26:32,361 --> 00:26:36,361
and inside the package,
this is your development package.

493
00:26:37,008 --> 00:26:40,418
You can see R, just click 
on this <i>R.java</i> file

494
00:26:40,418 --> 00:26:43,418
and you can go back to Android now.

495
00:26:44,079 --> 00:26:46,429
So this is your Android <i>R.java</i>
you can see that file

496
00:26:46,429 --> 00:26:49,049
under the <i>build folder</i> are generated
and should not be edited.

497
00:26:49,049 --> 00:26:51,349
So you are not to tamper with this file.

498
00:26:51,349 --> 00:26:55,239
I'm just showing you this 
to prove my point

499
00:26:55,239 --> 00:26:58,776
that everything you put inside 
your <i>res folder</i> is registered here.

500
00:26:58,776 --> 00:27:03,539
So I'm gonna find my <i>ActivityMain</i> first.

501
00:27:03,704 --> 00:27:06,468
Anything you put inside your <i>res folder</i>

502
00:27:06,468 --> 00:27:08,918
will get registered inside 
your <i>R.java file</i>

503
00:27:08,918 --> 00:27:11,968
but in the same way 
that you're defining it.

504
00:27:11,968 --> 00:27:14,968
Like your layout file 
that is <i>Activity_Main.xml</i>,

505
00:27:15,366 --> 00:27:17,106
you have to find inside 
a layout folder,

506
00:27:17,106 --> 00:27:20,046
so it will be inside your <i>R.java folder</i>

507
00:27:20,046 --> 00:27:21,576
but inside a <i>class layout</i>.

508
00:27:21,576 --> 00:27:24,167
So... <i>Class Layout</i>.

509
00:27:24,167 --> 00:27:26,997
You can see <i>class layout</i>
and then inside that,

510
00:27:26,997 --> 00:27:28,340
the name <i>ActivityMain</i>.

511
00:27:28,340 --> 00:27:30,150
[inaudible]

512
00:27:30,150 --> 00:27:33,242
Yeah, there we go.
So you can see the entry here now.

513
00:27:33,242 --> 00:27:35,642
In the same way, let's talk about <i>mipmap</i>.

514
00:27:35,642 --> 00:27:38,473
So <i>mipmap</i> will be registered 
inside the <i>R.java file</i>

515
00:27:38,473 --> 00:27:40,643
but with <i>class mipmap</i>.

516
00:27:40,643 --> 00:27:43,153
You can see here under <i>ic_launcher</i>.

517
00:27:43,153 --> 00:27:45,643
Mainly this is just one image, right?

518
00:27:45,643 --> 00:27:48,983
So with just one name, so that's why 
there is only one entry.

519
00:27:49,997 --> 00:27:54,977
I just saved a bunch of colors there
so to check out colors

520
00:27:55,508 --> 00:27:58,838
which class will it be saved in?
Color.

521
00:27:59,719 --> 00:28:01,109
Resources color.

522
00:28:01,762 --> 00:28:03,962
As you can see, the tag is color here.

523
00:28:03,962 --> 00:28:05,183
So, color.

524
00:28:05,183 --> 00:28:07,483
And inside color you can now find out

525
00:28:07,483 --> 00:28:09,193
what is the name by which you saved.

526
00:28:09,193 --> 00:28:11,592
<i>ColorPrimary, ColorDark, 
ColorAccent</i> and <i>Title_Color</i>.

527
00:28:11,592 --> 00:28:14,852
So you just have to find out
the <i>ColorPrimary, ColorDark</i>...

528
00:28:17,451 --> 00:28:21,456
Yeah, see, <i>ColorPrimary, ColorDark, 
ColorPrimary Dark</i>

529
00:28:21,456 --> 00:28:23,276
and the <i>Title</i>.

530
00:28:24,206 --> 00:28:26,436
I included my own, <i>TitleColor</i>.

531
00:28:28,761 --> 00:28:31,211
So it will be somewhere around here

532
00:28:37,553 --> 00:28:41,293
If anything is not there, 
you can even rebuild your project

533
00:28:49,999 --> 00:28:52,009
and sync it now.

534
00:29:00,033 --> 00:29:04,423
Okay, now find color, class, color.

535
00:29:05,085 --> 00:29:09,085
So we have already seen 
that <i>ColorPrimary, ColorDark</i>.

536
00:29:11,761 --> 00:29:12,981
Sorry, color.

537
00:29:14,981 --> 00:29:19,541
<i>ColorPrimary, ColorDark, 
ColorAccent,ColorPrimary Dark</i>

538
00:29:19,541 --> 00:29:22,341
And there's <i>TitleColor</i>. 
Yeah, there we go.

539
00:29:22,341 --> 00:29:24,786
<i>TitleColor</i>, which we saved here, right?

540
00:29:24,786 --> 00:29:27,496
So any resource you create,
there will be an entry.

541
00:29:27,496 --> 00:29:28,732
Now you can see...

542
00:29:29,768 --> 00:29:34,218
In the same way there is 
a dimension folder or <i>dimens</i> folder.

543
00:29:34,218 --> 00:29:36,423
Inside which we are defining some spaces.

544
00:29:36,423 --> 00:29:41,354
<i>Dimens</i> are used to define blank spaces

545
00:29:41,354 --> 00:29:44,434
and putting some horizontal margin.

546
00:29:44,434 --> 00:29:47,977
That is 16dp for the default screen size.

547
00:29:48,518 --> 00:29:51,378
But if the same screen size is a tablet,

548
00:29:51,378 --> 00:29:55,948
or a screen size with a 7 inch screen,
or 10 inch screen

549
00:29:55,948 --> 00:29:59,088
the same horizontal margin will become 64.

550
00:29:59,438 --> 00:30:03,558
Can you see that? 
The name of <i>Activity_Horizontal_Margin</i>

551
00:30:03,558 --> 00:30:06,358
is the same as <i>Activity_Horizontal_Margin</i>.

552
00:30:06,358 --> 00:30:09,534
So Android will automatically detect
which device it's running

553
00:30:09,534 --> 00:30:11,489
whether it's a tablet or a device.

554
00:30:11,489 --> 00:30:15,284
Accordingly, it will pick one 
of these resources

555
00:30:15,284 --> 00:30:17,024
whenever they are being used.

556
00:30:17,024 --> 00:30:20,174
I still need to tell you 
how to use these resources but...

557
00:30:20,174 --> 00:30:23,470
Know that this will get an entry
inside of your <i>R.java file</i>

558
00:30:25,420 --> 00:30:27,730
<i>Dimens</i>... Yeah, you can see that.

559
00:30:29,604 --> 00:30:33,054
There will be an <i>activity_</i>...

560
00:30:33,054 --> 00:30:35,543
Yeah. <i>Activity_Horizontal_Margin</i>

561
00:30:35,543 --> 00:30:38,053
and <i>_Vertical</i>.

562
00:30:38,053 --> 00:30:39,553
Next...<i>String</i>.

563
00:30:39,553 --> 00:30:42,480
So you can see here 
there is a string also.

564
00:30:43,147 --> 00:30:46,491
I have created under resources string
with the app name

565
00:30:46,491 --> 00:30:48,021
<i>My-Hello-First-App</i>.

566
00:30:48,021 --> 00:30:51,222
The reason here is... See here.

567
00:30:51,222 --> 00:30:53,562
Every time you open up your app,

568
00:30:53,562 --> 00:30:56,983
you'll see this <i>My Hello first App</i>

569
00:30:56,983 --> 00:30:59,803
that is because you have to find it here.

570
00:30:59,803 --> 00:31:02,409
Now, let us see how exactly I use this,

571
00:31:02,409 --> 00:31:04,289
how exactly I use my resources.

572
00:31:04,289 --> 00:31:06,169
You must have seen in your manifest file,

573
00:31:06,169 --> 00:31:09,428
when you go to your manifest file
I told you that icon--

574
00:31:09,428 --> 00:31:11,458
this icon is used to set my icon.

575
00:31:11,458 --> 00:31:13,114
But, how exactly, it's setting my icon

576
00:31:13,114 --> 00:31:18,424
because there is <i>@mipmap/ic_launcher</i>

577
00:31:18,424 --> 00:31:23,174
so <i>@mipmap</i> means I'm going
or I'm referring to my <i>mipmap class</i>.

578
00:31:23,468 --> 00:31:27,038
<i>@</i> first of all, let's 
just talk about what is <i>@</i>.

579
00:31:27,689 --> 00:31:30,479
If you are defining or if you are
accessing your resources

580
00:31:30,479 --> 00:31:33,699
If you want to access a resource,<i>
mipmap</i> is what? A resource.

581
00:31:34,615 --> 00:31:37,828
If you want to access a resource 
inside a XML file

582
00:31:37,828 --> 00:31:42,068
you'll be using <i>@</i> to denote 
your <i>R.java file</i>.

583
00:31:42,506 --> 00:31:46,506
This <i>@</i> right now is denoting
or is referring to my <i>R.java</i>.

584
00:31:46,957 --> 00:31:48,767
So first statement will do what?

585
00:31:48,767 --> 00:31:51,257
@ that means it goes to <i>R.java file</i>

586
00:31:51,257 --> 00:31:55,957
and inside <i>R.java file</i> which class 
I want to go ahead with?

587
00:31:55,957 --> 00:31:57,397
That is <i>mipmap</i>.

588
00:31:57,397 --> 00:32:01,307
So it will start searching 
for <i>class mipmap</i>.

589
00:32:02,578 --> 00:32:06,998
So inside <i>mipmap</i> also
which file it want? <i>Ic_launcher</i>

590
00:32:06,998 --> 00:32:08,821
So is there an <i>ic_launcher</i>? Yes.

591
00:32:08,821 --> 00:32:12,282
So that's the reason you were able
to see the icon here.

592
00:32:12,282 --> 00:32:15,862
You were able to see this icon.

593
00:32:15,862 --> 00:32:19,892
If you want to change the icon
just give some other icon.

594
00:32:19,892 --> 00:32:21,699
If you have any other image here

595
00:32:21,699 --> 00:32:24,559
you can give any other image 
and the icon will change.

596
00:32:24,559 --> 00:32:27,389
Let me just check 
if I have any other image--

597
00:32:42,577 --> 00:32:46,271
Let me just copy this 
and paste it here

598
00:32:46,271 --> 00:32:48,081
inside the <i>drawable</i>.

599
00:32:48,081 --> 00:32:50,856
I'm putting it in <i>drawable</i>
but you can put it in <i>mipmap</i> also,

600
00:32:50,856 --> 00:32:54,996
if you have more then one icon

601
00:32:54,996 --> 00:32:59,917
or different resolution size 
of the same image.

602
00:32:59,917 --> 00:33:03,977
So, if I'm a referring it 
from <i>drawable</i>, this time ,

603
00:33:03,977 --> 00:33:06,237
how, exactly, will I be referring it?

604
00:33:06,237 --> 00:33:08,888
Again, go to the <i>R.java file</i>
by using @,

605
00:33:08,888 --> 00:33:11,908
but this time I won't be using <i>
mipmap</i>, I'll be using <i>drawable</i>.

606
00:33:12,543 --> 00:33:15,293
You can see in the <i>drawable</i>
there is an dog icon.

607
00:33:15,293 --> 00:33:17,103
So if I run this...

608
00:33:17,103 --> 00:33:20,233
Just make sure if you are using icons,

609
00:33:20,233 --> 00:33:24,273
those icons should be 
actually compatible to the icon size.

610
00:33:24,273 --> 00:33:27,934
You can't expect a big icon size

611
00:33:27,934 --> 00:33:30,344
or big image to become an icon.

612
00:33:30,344 --> 00:33:34,304
So I don't know if my image 
is actually an icon... yeah.

613
00:33:34,304 --> 00:33:35,920
It was compatible to that.

614
00:33:35,920 --> 00:33:38,340
So you can see here,<i>
My Hello App</i>--

615
00:33:39,584 --> 00:33:41,044
now the icon has changed.

616
00:33:41,044 --> 00:33:43,504
So in this way you can use the resources.

617
00:33:43,783 --> 00:33:46,873
Every time you want to use 
resource inside a <i>res folder</i>

618
00:33:46,873 --> 00:33:49,643
you'll be using <i>@</i>
and the <i>class name</i>.

619
00:33:49,643 --> 00:33:51,853
So in the same way you can see <i>label</i>.

620
00:33:51,853 --> 00:33:55,883
<i>Label</i> is one of the titles you see here.

621
00:33:55,883 --> 00:33:58,430
As you can see, I have <i>MyHelloFirstApp</i>

622
00:33:58,430 --> 00:34:02,520
how exactly it's picking up <i>
@string</i> in the resource folder,

623
00:34:02,520 --> 00:34:05,260
there is a <i>string</i>. 
an <i>@ string</i>.

624
00:34:07,970 --> 00:34:11,410
And inside the <i>string</i>
there is a name <i>App_Name</i>.

625
00:34:12,790 --> 00:34:14,600
Did I define this resource? Yeah.

626
00:34:14,600 --> 00:34:17,309
You can see in this <i>string</i>, 
I defined <i>string</i>

627
00:34:17,309 --> 00:34:19,239
and the <i>string</i> is <i>app_name</i>.

628
00:34:19,239 --> 00:34:21,779
If I change this here...

629
00:34:23,458 --> 00:34:26,458
<i>First App</i>.

630
00:34:27,617 --> 00:34:30,767
So now I don't have 
to worry about changing it there.

631
00:34:32,206 --> 00:34:33,745
It'll automatically get changed

632
00:34:33,745 --> 00:34:36,605
and every time 
you open your application now,

633
00:34:36,605 --> 00:34:41,075
there will be the title <i>First App</i>,
instead of <i>MyHelloFirstApp</i>.

634
00:34:41,571 --> 00:34:44,281
So you see <i>First App</i>.
There you go.

635
00:34:45,310 --> 00:34:48,683
So I hope this makes things clear

636
00:34:48,683 --> 00:34:51,633
in the same way you can 
check all these styles.

637
00:34:52,170 --> 00:34:53,590
<i>Style</i> gives you--

638
00:34:54,730 --> 00:34:57,051
<i>Style</i> is, again, one of the resource

639
00:34:57,051 --> 00:35:00,051
which tells how exactly 
your application will look like,

640
00:35:00,051 --> 00:35:03,890
so, in this particular style 
you can see that I am using a theme.

641
00:35:03,890 --> 00:35:08,000
That theme is also<i>
Theme.AppCompat.Light.DarkActionBar</i>.

642
00:35:08,000 --> 00:35:10,240
Now this <i>appcompat</i> is very crucial

643
00:35:10,240 --> 00:35:13,930
because in your Java or in your Activity

644
00:35:13,930 --> 00:35:16,526
you are using <i>AppCompat Activity</i>.

645
00:35:16,526 --> 00:35:20,232
If you would be using
a normal <i>Activity file</i> here,

646
00:35:20,232 --> 00:35:22,802
now, at that point of time,
the syntax is right,

647
00:35:22,802 --> 00:35:24,802
but when you run this application,

648
00:35:24,802 --> 00:35:28,042
the theme will not be compatible 
with the [source].

649
00:35:28,922 --> 00:35:31,982
The UI you want is not the--

650
00:35:31,982 --> 00:35:34,756
You may not get the same UI that you want.

651
00:35:34,756 --> 00:35:37,485
If you are using Activity 
then according to that Activity,

652
00:35:37,485 --> 00:35:39,635
there will be a different theme.

653
00:35:39,635 --> 00:35:41,395
So I'm using <i>AppCompat</i>,

654
00:35:41,395 --> 00:35:44,083
so for <i>AppCompat</i>,
I'm using the <i>AppCompat theme</i>.

655
00:35:44,083 --> 00:35:45,983
Light and Dark action bar.

656
00:35:45,983 --> 00:35:50,103
And you can see I'm customizing it
by using one of the items.

657
00:35:50,103 --> 00:35:53,158
I'm going to customize one of the items
known as <i>ColorPrimary</i>.

658
00:35:53,158 --> 00:35:56,008
And here you can see <i>Asset</i>
is a XML file, right?

659
00:35:56,008 --> 00:35:57,763
So I won't be using colors,

660
00:35:57,763 --> 00:36:01,993
it will be <i>@color/colorprimary</i>.

661
00:36:01,993 --> 00:36:03,616
I have already defined a <i>@color</i>.

662
00:36:03,616 --> 00:36:07,194
Isn't it in the color file? 
@color, color file--

663
00:36:07,194 --> 00:36:08,504
Great!

664
00:36:08,504 --> 00:36:10,764
In the same way 
I'm customizing other also...

665
00:36:10,764 --> 00:36:13,944
Let's say I don't want 
to put color primary,

666
00:36:13,944 --> 00:36:16,264
I want to use my color
which I have just defined.

667
00:36:16,264 --> 00:36:17,624
So it is <i>title_color</i>.

668
00:36:18,834 --> 00:36:22,024
So now, if you run this 
you will be able

669
00:36:22,024 --> 00:36:25,534
to see the color has changed.

670
00:36:25,534 --> 00:36:29,038
So this is how your resource 
of file works

671
00:36:29,038 --> 00:36:30,948
around in your Android.

672
00:36:30,948 --> 00:36:36,205
So this how you access your
resource file inside the XML.

673
00:36:36,205 --> 00:36:37,705
That is by using @.

674
00:36:37,705 --> 00:36:40,268
If you want to access 
your resource file in your Java--

675
00:36:40,268 --> 00:36:43,168
As you can see 
I have attached this layout,

676
00:36:43,168 --> 00:36:45,428
attached this file which 
is defined in <i>Layout</i>

677
00:36:45,428 --> 00:36:50,078
inside my Java file,
inside my <i>Activity</i>

678
00:36:50,460 --> 00:36:52,869
with the help of resource file only.

679
00:36:52,869 --> 00:36:55,609
So if you are accessing a <i>R.java file</i>

680
00:36:55,609 --> 00:36:58,261
inside your Java folder,

681
00:36:58,261 --> 00:36:59,771
then you will be using <i>.operator</i>

682
00:36:59,771 --> 00:37:03,061
You can see, again, I'm using<i>
R</i>, this time no @

683
00:37:03,061 --> 00:37:06,061
<i>R</i>, then <i>dot</i> and then, 
the class name that is <i>layout</i>.

684
00:37:06,061 --> 00:37:09,848
And then, the file name
which you want to process.

685
00:37:09,848 --> 00:37:12,258
That's how you'll be accessing it.

686
00:37:12,902 --> 00:37:16,512
Ok so, that was an overview

687
00:37:16,512 --> 00:37:19,491
on Android Studio 
and the Project Data Key.

688
00:37:19,491 --> 00:37:23,001
And what are the different components 
you see in your Android studio.

689
00:37:23,001 --> 00:37:25,504
I hope this will help you 
in understanding

690
00:37:25,504 --> 00:37:27,084
your Android Studio better.

691
00:37:27,084 --> 00:37:31,084
In further session we will learn more 
about designing UIs

692
00:37:31,613 --> 00:37:34,893
and how exactly we can work 
around with our screens and all.

693
00:37:35,623 --> 00:37:38,511
So that's it from my side 
an introduction

694
00:37:38,511 --> 00:37:40,211
to Android Studio and Android.

695
00:37:40,211 --> 00:37:41,461
Thank you

696
00:37:41,461 --> 00:37:45,091
♪ (robotic music) ♪


