1
00:00:00,630 --> 00:00:07,890
And here are actually I need to show this program Stalock to the user so I can just type in progress

2
00:00:07,990 --> 00:00:12,670
larg progress dialog that show.

3
00:00:12,780 --> 00:00:18,690
So now it's going actually show this message to the user on this preexist cute method and here as you

4
00:00:18,690 --> 00:00:21,120
can see I mean scientists doing background.

5
00:00:21,180 --> 00:00:25,940
So this is the Meffert that is actually going to download the image from the internet in the background.

6
00:00:25,940 --> 00:00:28,260
The key not the user interface for it.

7
00:00:28,290 --> 00:00:31,190
So let's actually delete this line of code here returns.

8
00:00:31,530 --> 00:00:36,600
And here I'm actually putting some lines of code here so I'm going to paste in some lines of code here

9
00:00:36,630 --> 00:00:39,290
and then I'm going explain to you what's going on here.

10
00:00:39,390 --> 00:00:44,520
So as you can see here these are the lines of code that actually pasted here.

11
00:00:44,790 --> 00:00:49,410
And inside this method as you can see I created of the table of type.

12
00:00:49,420 --> 00:00:51,760
Strange as you can see here in line 18.

13
00:00:51,870 --> 00:00:54,230
And the name of this valuable is strange.

14
00:00:54,240 --> 00:00:56,970
You are an assignment operator.

15
00:00:57,180 --> 00:01:00,040
So here I'll refer to this part arms array.

16
00:01:00,090 --> 00:01:03,160
So remember is permitted is actually of type.

17
00:01:03,210 --> 00:01:08,310
Ali I told you about this type of Aure in the jobs section of the course.

18
00:01:08,340 --> 00:01:08,890
OK.

19
00:01:09,250 --> 00:01:11,210
Putnam's as you can see here.

20
00:01:11,700 --> 00:01:14,880
And here I am actually putting this Index index zero.

21
00:01:15,090 --> 00:01:15,670
OK.

22
00:01:15,990 --> 00:01:19,490
So here as you can see I have this Aure and this is going to be the index 0.

23
00:01:19,500 --> 00:01:26,460
And this means that when you want to actually download an image from the internet you need to actually

24
00:01:26,460 --> 00:01:36,300
pass a pedometer an argument in order to actually for example lead the application know that I want

25
00:01:36,300 --> 00:01:41,570
to download an image from the Internet's 5:22 you are able to that specific method.

26
00:01:41,620 --> 00:01:42,510
OK.

27
00:01:42,990 --> 00:01:45,210
And I'll show you that Meffert in a minute.

28
00:01:45,710 --> 00:01:48,910
And here as you can see this is going to be the data type of that method.

29
00:01:48,930 --> 00:01:51,070
As you can see and we have an array.

30
00:01:51,120 --> 00:01:51,690
OK.

31
00:01:52,020 --> 00:01:55,860
So the index zero of that array is going to be that you are.

32
00:01:55,940 --> 00:01:56,220
OK.

33
00:01:56,220 --> 00:02:01,890
Because I want to download an image only one image from the internet so you have only one of your RL

34
00:02:02,190 --> 00:02:08,410
so that you are it is going to be placed inside the index zero of this alley of this prom's addy.

35
00:02:08,460 --> 00:02:08,970
OK.

36
00:02:09,030 --> 00:02:12,340
So that's why I actually would put this perhaps.

37
00:02:12,440 --> 00:02:18,600
Here are you referred to the name of this Ali and I put this in zero here because I have I have only

38
00:02:18,600 --> 00:02:19,770
one you are.

39
00:02:19,890 --> 00:02:21,830
So I just put this you are a zero.

40
00:02:22,170 --> 00:02:28,400
And then it's going to actually download the image from the Internet by using that specific you are

41
00:02:28,410 --> 00:02:28,740
ill.

42
00:02:28,820 --> 00:02:30,980
He had that I actually specify here.

43
00:02:31,260 --> 00:02:34,230
So here you referred to the name of this part.

44
00:02:34,330 --> 00:02:34,760
OK.

45
00:02:34,880 --> 00:02:38,530
Perhaps Ari Suppe index zero as you can see here.

46
00:02:38,730 --> 00:02:40,900
So this is going to be that you all OK.

47
00:02:41,100 --> 00:02:46,860
And here I am assigning that specific humoral to this string you are in here that I actually created

48
00:02:46,860 --> 00:02:47,340
here.

49
00:02:47,430 --> 00:02:48,280
OK.

50
00:02:48,720 --> 00:02:56,790
And in light ativan I actually created an object of type bitmap and then I assigned a value to this

51
00:02:56,840 --> 00:02:57,900
bitmap object.

52
00:02:57,900 --> 00:03:00,790
So here I have this try catch exception here.

53
00:03:01,710 --> 00:03:08,760
And hid inside the trite statement here as you can see in the try block here I have this I have these

54
00:03:08,760 --> 00:03:09,590
lines of quote.

55
00:03:09,750 --> 00:03:15,320
First of all I created an object of type you r l and the name of this object is you are it.

56
00:03:15,720 --> 00:03:21,950
And here I am actually instantiating this you Arel by using this strange model that I created in line

57
00:03:22,030 --> 00:03:24,380
80 new you Ardell.

58
00:03:24,540 --> 00:03:30,450
So here I want to instantiate this you are an object by using this string you are that I actually get

59
00:03:31,550 --> 00:03:35,160
to use that one through example with an image from the Internet.

60
00:03:35,250 --> 00:03:39,080
So remember that I told you about this you are here.

61
00:03:39,160 --> 00:03:41,490
This is going to be inserted double quotes.

62
00:03:41,640 --> 00:03:42,850
So this is going to be.

63
00:03:42,860 --> 00:03:44,790
And actually when you are ill.

64
00:03:45,040 --> 00:03:47,050
So insight and anthrax to do.

65
00:03:47,070 --> 00:03:52,230
Now you can see that you want to actually use this strange model in order to download an image from

66
00:03:52,230 --> 00:03:53,150
the Internet.

67
00:03:53,190 --> 00:03:56,080
So that's why I created this you are an object.

68
00:03:56,310 --> 00:04:02,070
And then in order to download an image from the union we need to actually create an object of type input

69
00:04:02,070 --> 00:04:05,510
stream and the name of this object is in input stream.

70
00:04:05,610 --> 00:04:12,510
Assignment operator you are ill that open stream so it can actually open the website that we want to

71
00:04:12,510 --> 00:04:15,960
actually download an image from the Internet.

72
00:04:16,140 --> 00:04:19,520
And here I referred to the name of this bitmap object.

73
00:04:19,560 --> 00:04:20,090
OK.

74
00:04:20,310 --> 00:04:23,170
So bitmap factory D-CT stream.

75
00:04:23,190 --> 00:04:23,980
So it's clear here.

76
00:04:24,060 --> 00:04:29,280
This is going to actually download that specific Meffert that specific image from that stream.

77
00:04:29,280 --> 00:04:36,810
Here are two input stream that decode stream input stream or keep it back to the class that decode stream

78
00:04:36,840 --> 00:04:41,040
input stream so it can actually return an object of type bitmap.

79
00:04:41,040 --> 00:04:47,160
So it's going to actually assign that object to this bitmap object that is going to assign that image

80
00:04:47,190 --> 00:04:48,280
to this bitmap object.

81
00:04:48,280 --> 00:04:48,800
OK.

82
00:04:49,140 --> 00:04:51,570
And here I have this catch statement.

83
00:04:51,600 --> 00:04:55,430
So this catch block is going actually is going to be executed of any.

84
00:04:55,440 --> 00:05:01,500
For example when downloading the image from the Internet from the Internet is going to actually fail.

85
00:05:01,560 --> 00:05:07,700
So you need to catch this error here and we can actually put that to the log.

86
00:05:07,740 --> 00:05:10,380
So for example catch that print is text.

87
00:05:10,380 --> 00:05:14,170
It prints that traces can actually put the information to the lug.

88
00:05:14,640 --> 00:05:20,190
And here we are returning that object returned bitmap from the background.

89
00:05:20,220 --> 00:05:25,820
So when the image is actually downloaded from the Internet it's going to return.

90
00:05:26,340 --> 00:05:31,870
It's going to return the bitmap object and inside our unposed execute Meffert.

91
00:05:31,890 --> 00:05:36,110
As you can see we have this bitmap object as a pad image OK.

92
00:05:36,600 --> 00:05:43,110
I have this beaten up other object as a pad emitter as you can see this object that is returned from

93
00:05:43,110 --> 00:05:44,180
the screen background.

94
00:05:44,230 --> 00:05:49,290
It is going to be as a pad image here of this unposted execute.

95
00:05:49,320 --> 00:05:56,960
So this Meffert is going to be run on the UI for it so I can actually show that image to the user.

96
00:05:56,970 --> 00:06:00,710
So in order to do that again just take the image view that.

97
00:06:00,780 --> 00:06:06,050
So as you can see here I am referring to this image inside these outer class main activity class.

98
00:06:06,120 --> 00:06:11,470
So here I can just take an image that sets image bitmap as you can see here.

99
00:06:11,670 --> 00:06:16,440
I can actually assign an object of type bitmap here bitmap.

100
00:06:16,450 --> 00:06:23,640
OK so now because I am actually inside this and post execute Meffert and this means that this method

101
00:06:23,640 --> 00:06:31,380
actually runs on the UI thread I can actually I need to actually stop showing this progress day luck

102
00:06:31,710 --> 00:06:36,020
that I actually started showing here in line in an execute Nefert.

103
00:06:36,120 --> 00:06:38,670
I need to actually stop showing that progress.

104
00:06:38,670 --> 00:06:43,620
I like to use that because the image is actually downloaded from the internet so here I can't just create

105
00:06:43,620 --> 00:06:48,860
an if statement if progress dialog that is showing.

106
00:06:49,680 --> 00:06:58,180
And inside this statement I can't just they can progress they lag that dismiss so now let's say our

107
00:06:58,180 --> 00:06:59,920
project and see what happens.

108
00:07:00,100 --> 00:07:06,970
So before running our project as you can see I have this error here and I actually mistakenly assigned

109
00:07:07,030 --> 00:07:14,410
this rank ID for the speaker and download the actual ID of this PTEN download is between download image.

110
00:07:14,410 --> 00:07:14,880
OK.

111
00:07:14,920 --> 00:07:23,200
So let's actually change this up PTEN download here to between download image and now here at the top

112
00:07:23,230 --> 00:07:28,400
in our main activity class let's change this the name of the city and download to PTEN download image.

113
00:07:28,400 --> 00:07:29,070
OK.

114
00:07:29,480 --> 00:07:35,490
But as you can see here again architecture will change the speed and download to PTEN download image.

115
00:07:35,990 --> 00:07:37,420
And now the errors are gone.

116
00:07:37,430 --> 00:07:41,640
OK so now let's actually run our project and see what happens.

117
00:07:41,770 --> 00:07:45,710
So now as you can see our application is running on the simulator.

118
00:07:45,720 --> 00:07:50,710
So if we click on the spot in here it's not going to actually download the image from the Internet.

119
00:07:50,860 --> 00:07:57,340
So there is a problem here and the problem is that we didn't we didn't actually put the logic inside

120
00:07:57,430 --> 00:08:01,150
this uncle Mefford in order to download that image from the Internet.

121
00:08:01,330 --> 00:08:06,610
So first of all in order to download an image from the Internet we need to actually create an object

122
00:08:07,120 --> 00:08:09,270
of type download image task class.

123
00:08:09,280 --> 00:08:14,490
OK so this class is actually responsible for downloading the image from the Internet.

124
00:08:14,500 --> 00:08:20,140
So in order to download this image from the internet I need to create an object of type download image

125
00:08:20,140 --> 00:08:20,800
task.

126
00:08:21,010 --> 00:08:26,950
So the name of this object is download image task assignment operator new download image task and as

127
00:08:26,950 --> 00:08:32,800
you can see here for the constructor of this class I specified that this class accepts an argument of

128
00:08:32,800 --> 00:08:33,880
type context.

129
00:08:33,970 --> 00:08:41,230
So the context is going to be main activity that this semicolon and then here I can just type in download

130
00:08:41,230 --> 00:08:50,470
image task I referred to the name of this download image task object that executes at inside Apprentice's

131
00:08:50,860 --> 00:08:53,860
of this download of this execute Meffert as you can see here.

132
00:08:53,860 --> 00:08:58,030
I have this pattern is a part of type A string of a.

133
00:08:58,210 --> 00:09:00,550
So here I need to put you out of here.

134
00:09:00,700 --> 00:09:03,300
So here are inside this Apprentice's.

135
00:09:03,310 --> 00:09:09,780
I can just put into double quotes and in our Web browser as you can see I have this you are all here.

136
00:09:09,790 --> 00:09:10,300
OK.

137
00:09:10,360 --> 00:09:16,570
So I just need to copy this you are RL And inside these double codes I can put that you are all here

138
00:09:17,020 --> 00:09:21,230
and at the end of my statement I need to put up put a semicolon here.

139
00:09:21,250 --> 00:09:26,880
So this is going to be my you are l and I called this execute my foot on this download image task object.

140
00:09:26,890 --> 00:09:30,670
So let's run our project again and this time let's see what happens.

141
00:09:30,670 --> 00:09:35,450
So as you can see here our application is running on this emulator here.

142
00:09:35,800 --> 00:09:40,420
And now let's actually click on the spot in here download an image from the Internet.

143
00:09:40,690 --> 00:09:44,490
And as you can see here I cannot download this image from the Internet.

144
00:09:44,500 --> 00:09:46,480
So now what's the problem.

145
00:09:46,480 --> 00:09:52,590
The problem is inside the Android manifest as you can see here inside this manifest file.

146
00:09:52,690 --> 00:10:00,370
We need to put put actually a permission in order to actually get the permission of the user in order

147
00:10:00,370 --> 00:10:05,380
to access the Internet because they want to use the Internet in order to download an image from the

148
00:10:05,380 --> 00:10:05,970
Internet.

149
00:10:06,160 --> 00:10:10,500
So here I need to put that permission is this manifest tagging as you can see here.

150
00:10:10,600 --> 00:10:11,950
I need to put that permission.

151
00:10:11,950 --> 00:10:14,970
So here I need to open this permission here.

152
00:10:14,980 --> 00:10:22,570
This tag uses permission and inside the double quotes I can just type in Internet and select this one

153
00:10:22,990 --> 00:10:25,540
and then close this permission here.

154
00:10:25,570 --> 00:10:28,810
So now I can actually run our project again.

155
00:10:28,870 --> 00:10:33,350
So here as you can see our application is running on this emulator.

156
00:10:33,460 --> 00:10:36,330
So let's actually click on the spot in here again.

157
00:10:36,670 --> 00:10:40,470
And now as you can see we can see this progress dialog downloading image.

158
00:10:40,470 --> 00:10:41,250
Please wait.

159
00:10:41,320 --> 00:10:46,670
And here we can see this image and we successfully download this image from the Internet.

160
00:10:46,930 --> 00:10:47,890
OK.

161
00:10:48,400 --> 00:10:55,060
So I think that's enough for this tutorial and I think you can you can actually figure out how to download

162
00:10:55,060 --> 00:10:57,400
an image from the internet now.

163
00:10:57,670 --> 00:11:03,250
So if you have any questions please post the discussion in the course and then I'll do my best to answer

164
00:11:03,340 --> 00:11:04,610
all of your questions.

165
00:11:04,870 --> 00:11:08,410
Thank you very much for watching and I'll see you in the next tutorial.

