WEBVTT

1
00:00:00.080 --> 00:00:02.359
<v Speaker 1>Welcome to the Depth Dive, where we take a stack

2
00:00:02.399 --> 00:00:06.040
<v Speaker 1>of information and really extract the most important nuggets of

3
00:00:06.080 --> 00:00:09.919
<v Speaker 1>knowledge and insight tailored just for you. Today, we're doing

4
00:00:09.960 --> 00:00:13.080
<v Speaker 1>something a little different. It's like a fascinating TimewARP. We're

5
00:00:13.119 --> 00:00:17.000
<v Speaker 1>diving into the Android Application Development Cookbook, second edition, which,

6
00:00:17.320 --> 00:00:19.640
<v Speaker 1>believe it or not, was published way back in March

7
00:00:19.679 --> 00:00:23.079
<v Speaker 1>twenty sixteen. Our mission here is basically to give you

8
00:00:23.120 --> 00:00:26.480
<v Speaker 1>a shortcut, a shortcut to understanding what Android app development

9
00:00:26.519 --> 00:00:29.839
<v Speaker 1>looked like, you know, nearly a decade ago. We'll uncover

10
00:00:29.920 --> 00:00:33.880
<v Speaker 1>the core ideas, some practical recipes for problems developers face then,

11
00:00:34.000 --> 00:00:36.039
<v Speaker 1>and maybe some surprising things that we're cutting edge and

12
00:00:36.079 --> 00:00:38.880
<v Speaker 1>see how much or maybe how little things have really changed.

13
00:00:39.359 --> 00:00:42.439
<v Speaker 1>Our main source is that cookbook by Rick Boyer and

14
00:00:42.520 --> 00:00:45.560
<v Speaker 1>Kyle mu It's very much designed for developers who learn

15
00:00:45.759 --> 00:00:48.560
<v Speaker 1>by doing a by jumping into code. It's literally broken

16
00:00:48.600 --> 00:00:51.600
<v Speaker 1>down into these recipes with sections like getting ready, how

17
00:00:51.600 --> 00:00:53.960
<v Speaker 1>to do it, how it works. So let's imagine you're

18
00:00:54.000 --> 00:00:56.280
<v Speaker 1>an Android dep back in twenty sixteen, staring at a

19
00:00:56.280 --> 00:00:59.280
<v Speaker 1>blank screen. What were the absolute first things you'd write?

20
00:00:59.439 --> 00:01:00.920
<v Speaker 1>What were those fundamental building block?

21
00:01:01.000 --> 00:01:03.799
<v Speaker 2>Yeah, it's really interesting looking back, what's fascinating is how

22
00:01:04.120 --> 00:01:07.760
<v Speaker 2>clearly the book lays out these core components that honestly

23
00:01:08.120 --> 00:01:11.319
<v Speaker 2>are still pretty foundational today, even of how we implement

24
00:01:11.319 --> 00:01:14.640
<v Speaker 2>them has evolved quite a bit. The absolute bedrock for

25
00:01:14.680 --> 00:01:17.719
<v Speaker 2>almost any Android app then, and you could argue still now,

26
00:01:17.959 --> 00:01:21.760
<v Speaker 2>were activity activities. Right, Think of an activity as like

27
00:01:22.120 --> 00:01:25.200
<v Speaker 2>a single screen in your app, or a distinct user

28
00:01:25.200 --> 00:01:28.719
<v Speaker 2>interface view every single screen, your main menu settings, a

29
00:01:28.719 --> 00:01:31.640
<v Speaker 2>photo viewer that would typically be its own activity, and

30
00:01:31.680 --> 00:01:35.359
<v Speaker 2>these were all declared in that central file, the Android

31
00:01:35.359 --> 00:01:36.480
<v Speaker 2>Manifest dot XML.

32
00:01:36.680 --> 00:01:39.120
<v Speaker 1>Ah, the manifest okay exactly.

33
00:01:39.120 --> 00:01:42.719
<v Speaker 2>And crucially specific things called intent filters in there, like

34
00:01:42.799 --> 00:01:45.959
<v Speaker 2>main and launcher. They told the system which activity was

35
00:01:45.959 --> 00:01:47.920
<v Speaker 2>the main entry point, you know, the one that gets

36
00:01:47.920 --> 00:01:49.519
<v Speaker 2>the icon on your phone's home screen.

37
00:01:49.640 --> 00:01:52.560
<v Speaker 1>Okay, So activities are like the individual rooms in a house,

38
00:01:52.599 --> 00:01:55.280
<v Speaker 1>and the Manifest is the blueprint saying this room is

39
00:01:55.319 --> 00:01:58.079
<v Speaker 1>the front door. Got it? But how did these rooms

40
00:01:58.079 --> 00:02:00.439
<v Speaker 1>talk to each other inside the same app, or even

41
00:02:00.560 --> 00:02:02.480
<v Speaker 1>like talking to other apps on the phone.

42
00:02:02.599 --> 00:02:07.040
<v Speaker 2>That's where the incredibly powerful intent object came in. It's

43
00:02:07.120 --> 00:02:09.199
<v Speaker 2>essentially a message object. Think of it as a way

44
00:02:09.199 --> 00:02:11.840
<v Speaker 2>to say I want to do something, Yeah, but without

45
00:02:11.879 --> 00:02:14.800
<v Speaker 2>needing to know exactly who we'll do it. So, for example,

46
00:02:14.879 --> 00:02:17.639
<v Speaker 2>you could use intents dot action view. You tell the system, hey,

47
00:02:17.639 --> 00:02:21.680
<v Speaker 2>I want to view this capacity URL maybe huh, and

48
00:02:21.680 --> 00:02:24.560
<v Speaker 2>Android would figure out okay, the default web browser should

49
00:02:24.599 --> 00:02:26.319
<v Speaker 2>handle this and launch it for you.

50
00:02:26.560 --> 00:02:28.800
<v Speaker 1>Right, So the app doesn't need to know which browser

51
00:02:28.879 --> 00:02:30.759
<v Speaker 1>the user has installed exactly.

52
00:02:30.919 --> 00:02:33.840
<v Speaker 2>And what was really clever and still is is that

53
00:02:33.879 --> 00:02:36.560
<v Speaker 2>different types of data could launch completely different apps. A

54
00:02:36.639 --> 00:02:39.360
<v Speaker 2>location might open a map app, a contact file might

55
00:02:39.400 --> 00:02:42.120
<v Speaker 2>open the contact app. It showed how flexible the system

56
00:02:42.199 --> 00:02:45.639
<v Speaker 2>was letting apps work together without hard coding dependencies.

57
00:02:45.840 --> 00:02:49.520
<v Speaker 1>That's huge, that interoperability. Okay, so that's talking between apps.

58
00:02:49.879 --> 00:02:53.039
<v Speaker 1>What about just moving between screens inside your own appic

59
00:02:53.319 --> 00:02:55.159
<v Speaker 1>from a list to a detail screen.

60
00:02:55.360 --> 00:02:59.800
<v Speaker 2>Intents handle that too. You just create an intent specifying

61
00:02:59.840 --> 00:03:03.080
<v Speaker 2>the target activity, say moving from your main activity to

62
00:03:03.240 --> 00:03:05.879
<v Speaker 2>a second activity. As simple as that, And if you

63
00:03:05.919 --> 00:03:09.199
<v Speaker 2>needed to send some information along, you'd use put extra.

64
00:03:10.080 --> 00:03:13.479
<v Speaker 2>It worked with name value pairs, like packing little bits

65
00:03:13.479 --> 00:03:14.960
<v Speaker 2>of data into the intent.

66
00:03:14.919 --> 00:03:17.199
<v Speaker 1>Like sticking a post it note on the message.

67
00:03:16.840 --> 00:03:18.879
<v Speaker 2>Pretty much yeah, exactly like a post it and the

68
00:03:19.000 --> 00:03:22.639
<v Speaker 2>receiving activity would just grab that data using methods like

69
00:03:23.000 --> 00:03:25.199
<v Speaker 2>get string extra looking for the name you give it.

70
00:03:25.280 --> 00:03:27.960
<v Speaker 1>Okay, And what if you needed to get something back

71
00:03:28.000 --> 00:03:31.360
<v Speaker 1>from that second screen. Let's say you launched a contact

72
00:03:31.360 --> 00:03:34.800
<v Speaker 1>picker and you need the phone number the user picked.

73
00:03:34.639 --> 00:03:37.879
<v Speaker 2>Ah, right, for that, you wouldn't just start the activity.

74
00:03:37.919 --> 00:03:40.840
<v Speaker 2>You'd use start activity for results the result makes sense,

75
00:03:41.360 --> 00:03:44.199
<v Speaker 2>and the result would come back to the original activity

76
00:03:44.520 --> 00:03:49.120
<v Speaker 2>in a special callback method on activity results. And for

77
00:03:49.360 --> 00:03:53.080
<v Speaker 2>apps doing lots of this, maybe calling different activities for results,

78
00:03:53.360 --> 00:03:55.840
<v Speaker 2>there was something called a request code. There's a number

79
00:03:55.879 --> 00:03:58.080
<v Speaker 2>you defined when you started the activity, so that when

80
00:03:58.159 --> 00:04:00.800
<v Speaker 2>on activity result was called, you could check that code

81
00:04:01.000 --> 00:04:05.479
<v Speaker 2>and know which request was returing its result. Kept things organized, right,

82
00:04:05.599 --> 00:04:08.080
<v Speaker 2>because the mobile world is just so dynamic, isn't it.

83
00:04:08.120 --> 00:04:10.199
<v Speaker 2>You're in an app, a phone call comes in, you

84
00:04:10.240 --> 00:04:13.439
<v Speaker 2>switch to another app, The system might even kill your

85
00:04:13.439 --> 00:04:15.680
<v Speaker 2>app in the background, off the needs memory. It feels

86
00:04:15.680 --> 00:04:18.839
<v Speaker 2>like a constant battle with the OS. So what did

87
00:04:18.839 --> 00:04:20.759
<v Speaker 2>this all mean for a developer trying to make an

88
00:04:20.800 --> 00:04:24.720
<v Speaker 2>app feel smooth and seamless even with all those interruptions.

89
00:04:24.839 --> 00:04:28.000
<v Speaker 1>That's the million dollar question really, and connecting this to

90
00:04:28.040 --> 00:04:30.839
<v Speaker 1>the bigger picture, understanding the activity life cycle was just

91
00:04:30.959 --> 00:04:35.920
<v Speaker 1>absolutely critical paramount for app stability user experience, especially back

92
00:04:35.959 --> 00:04:38.720
<v Speaker 1>then on devices that maybe didn't have tons of memory.

93
00:04:39.040 --> 00:04:43.000
<v Speaker 1>Think about this, just rotating your phone. Yeah, by default,

94
00:04:43.079 --> 00:04:46.160
<v Speaker 1>Android would completely destroy your current activity and then recreate

95
00:04:46.160 --> 00:04:46.839
<v Speaker 1>it from a scratch.

96
00:04:46.879 --> 00:04:48.600
<v Speaker 2>Wait, destroy it just for rotating?

97
00:04:48.680 --> 00:04:51.720
<v Speaker 1>Yeah, destroy and recreate, which, as you can imagine, could

98
00:04:51.759 --> 00:04:54.000
<v Speaker 1>lead to a really terrible user experience if you weren't

99
00:04:54.000 --> 00:04:57.639
<v Speaker 1>ready for it. All the user's input gone, the scroll

100
00:04:57.639 --> 00:04:58.720
<v Speaker 1>position lost.

101
00:04:58.920 --> 00:05:01.839
<v Speaker 2>Wow. Okay, so how did developers handle that? That's where

102
00:05:01.839 --> 00:05:04.720
<v Speaker 2>these life cycle callback methods were vital, Things like on

103
00:05:04.800 --> 00:05:08.399
<v Speaker 2>save instance state and on restore instance. On save instance

104
00:05:08.519 --> 00:05:10.759
<v Speaker 2>date gave you a chance right before the activity was

105
00:05:10.800 --> 00:05:14.519
<v Speaker 2>potentially destroyed to save small bits of data like user

106
00:05:14.519 --> 00:05:17.800
<v Speaker 2>input or UI state okay, And then if the activity

107
00:05:17.879 --> 00:05:21.360
<v Speaker 2>was recreated on restore instance state or on create what

108
00:05:21.399 --> 00:05:23.680
<v Speaker 2>would be called and you could get that save data

109
00:05:23.720 --> 00:05:25.800
<v Speaker 2>back and restore the state so the user could just

110
00:05:25.800 --> 00:05:26.920
<v Speaker 2>pick up where they left off.

111
00:05:27.079 --> 00:05:29.639
<v Speaker 1>So you had to manually save and restore anything important

112
00:05:29.639 --> 00:05:31.959
<v Speaker 1>every time a configuration might change, like rotation.

113
00:05:32.279 --> 00:05:32.800
<v Speaker 2>Pretty much.

114
00:05:32.920 --> 00:05:33.199
<v Speaker 1>Yes.

115
00:05:33.560 --> 00:05:38.720
<v Speaker 2>The book details the core life cycle states active, pause, stopped, destroyed,

116
00:05:39.079 --> 00:05:42.120
<v Speaker 2>and the methods tied to them. On create on resume,

117
00:05:42.720 --> 00:05:46.879
<v Speaker 2>on pause, on stop, on destroy. The US was described

118
00:05:46.920 --> 00:05:50.160
<v Speaker 2>as ruthless with resource management. If your app went into

119
00:05:50.199 --> 00:05:52.360
<v Speaker 2>the pause or stop state, it was fair game for

120
00:05:52.399 --> 00:05:54.160
<v Speaker 2>the OS to kill it to reclaim memory.

121
00:05:54.319 --> 00:05:56.439
<v Speaker 1>That sounds like a lot of manual work and potential

122
00:05:56.480 --> 00:05:57.000
<v Speaker 1>for bugs.

123
00:05:57.279 --> 00:06:01.279
<v Speaker 2>It absolutely was a major source of frustration. Bilbote's got

124
00:06:01.279 --> 00:06:05.079
<v Speaker 2>to be really careful about calling the superclass methods, understanding

125
00:06:05.120 --> 00:06:08.079
<v Speaker 2>when each callback fired what they could safely do in

126
00:06:08.120 --> 00:06:11.120
<v Speaker 2>each one. It's honestly one of the main reasons modern

127
00:06:11.160 --> 00:06:14.120
<v Speaker 2>Android development shifted towards things like view model from the

128
00:06:14.199 --> 00:06:15.720
<v Speaker 2>architecture components.

129
00:06:15.480 --> 00:06:19.079
<v Speaker 1>Right to abstract away some of that life cycle complexity exactly.

130
00:06:19.399 --> 00:06:24.199
<v Speaker 2>View models survive configuration changes like rotation, automatically holding UI

131
00:06:24.319 --> 00:06:27.240
<v Speaker 2>related data without you needing to manually save and restore

132
00:06:27.240 --> 00:06:31.160
<v Speaker 2>it in the activity nearly as much. It simplified things massively.

133
00:06:31.399 --> 00:06:33.959
<v Speaker 1>Okay, so we've got the basic structure with activities and

134
00:06:34.000 --> 00:06:36.759
<v Speaker 1>intents and a sense of the constant dance with the

135
00:06:36.759 --> 00:06:40.600
<v Speaker 1>OS life cycle. But an app is nothing without its interface.

136
00:06:41.040 --> 00:06:44.040
<v Speaker 1>This is where it gets really interesting, right, optimizing what

137
00:06:44.120 --> 00:06:47.560
<v Speaker 1>the user actually sees and interacts with. It's not just

138
00:06:47.560 --> 00:06:49.560
<v Speaker 1>what you put on screen, but how you put.

139
00:06:49.360 --> 00:06:52.800
<v Speaker 2>It there absolutely, and that raises the question, how do

140
00:06:52.879 --> 00:06:56.879
<v Speaker 2>you build a complex, good looking UI that still performs well,

141
00:06:57.160 --> 00:07:00.360
<v Speaker 2>especially considering the huge variety of Android devices out there.

142
00:07:00.399 --> 00:07:03.959
<v Speaker 2>Even back then, the techniques in the cookbook, even from

143
00:07:03.959 --> 00:07:08.199
<v Speaker 2>twenty sixteen, really emphasize that performance starts with design, and

144
00:07:08.240 --> 00:07:11.160
<v Speaker 2>the foundation of UI design was layouts and view.

145
00:07:10.959 --> 00:07:13.560
<v Speaker 1>Groups w groups. That's like a container precisely.

146
00:07:13.600 --> 00:07:16.240
<v Speaker 2>A view group is the base class for containers, and

147
00:07:16.360 --> 00:07:19.120
<v Speaker 2>layout classes, which inherit from view group, are what you

148
00:07:19.199 --> 00:07:22.319
<v Speaker 2>use to actually organize the UI elements, the buttons, the

149
00:07:22.360 --> 00:07:25.160
<v Speaker 2>text fields, the images. They define the structure.

150
00:07:25.480 --> 00:07:28.399
<v Speaker 1>What were the main layout types developers were using back then?

151
00:07:28.800 --> 00:07:32.600
<v Speaker 2>The book covers several key ones. Relative layout was really powerful.

152
00:07:32.720 --> 00:07:35.279
<v Speaker 2>It let you position views relative to each other or

153
00:07:35.360 --> 00:07:37.680
<v Speaker 2>relative to the parent container. You could say, this button

154
00:07:37.720 --> 00:07:39.920
<v Speaker 2>goes to the right of that text view or center

155
00:07:40.000 --> 00:07:43.720
<v Speaker 2>this image. Very flexible for complex screens. Okay, yeah, Linear

156
00:07:43.800 --> 00:07:47.360
<v Speaker 2>layout much simpler. It just arranged views one after another,

157
00:07:47.560 --> 00:07:50.360
<v Speaker 2>either vertically in a column or horizontally in a row.

158
00:07:50.439 --> 00:07:53.199
<v Speaker 1>Simple but probably useful, very and.

159
00:07:53.120 --> 00:07:56.800
<v Speaker 2>Its key feature was layout weight. This allowed views within

160
00:07:56.839 --> 00:08:00.199
<v Speaker 2>the linear layout to take up proportional space. Like one

161
00:08:00.199 --> 00:08:02.399
<v Speaker 2>element takes seventy percent of the width, the other takes

162
00:08:02.480 --> 00:08:05.480
<v Speaker 2>thirty percent. Super useful for dividing space.

163
00:08:05.319 --> 00:08:08.639
<v Speaker 1>Dynamically right and for grids like a calculator or a

164
00:08:08.639 --> 00:08:09.439
<v Speaker 1>photo gallery.

165
00:08:09.680 --> 00:08:12.839
<v Speaker 2>For grid like structures, there was table layout and grid layout.

166
00:08:12.920 --> 00:08:16.079
<v Speaker 2>They approached it slightly differently how they defined rows and columns,

167
00:08:16.480 --> 00:08:19.279
<v Speaker 2>but both serve that purpose. And of course you could

168
00:08:19.279 --> 00:08:22.079
<v Speaker 2>nest these layouts, put a linear layout inside a relative

169
00:08:22.160 --> 00:08:26.160
<v Speaker 2>layout inside another linear layout. That's how you built up

170
00:08:26.199 --> 00:08:28.480
<v Speaker 2>really complex UI hierarchies.

171
00:08:28.519 --> 00:08:31.040
<v Speaker 1>But nesting sounds like it could get complicated fast and

172
00:08:31.160 --> 00:08:34.039
<v Speaker 1>maybe slow things down. Were there tools to help optimize

173
00:08:34.039 --> 00:08:34.679
<v Speaker 1>these layouts?

174
00:08:34.720 --> 00:08:38.480
<v Speaker 2>You bet? Performance was definitely a concern. The cookbook highlights

175
00:08:38.519 --> 00:08:40.679
<v Speaker 2>a couple of essential tools from that era. First, the

176
00:08:40.759 --> 00:08:43.480
<v Speaker 2>hierarchy Viewer hierarchy veer. Yeah, there's a tool that let

177
00:08:43.519 --> 00:08:46.200
<v Speaker 2>you visually inspect your layout structure as a tree. You

178
00:08:46.200 --> 00:08:49.600
<v Speaker 2>could see how deeply nested things were, identify redundant layouts.

179
00:08:49.960 --> 00:08:53.000
<v Speaker 2>Super useful for fine bottlenecks. The catch was, back then

180
00:08:53.039 --> 00:08:55.480
<v Speaker 2>it usually required a rooted device or an emulator to

181
00:08:55.559 --> 00:08:55.840
<v Speaker 2>use it.

182
00:08:56.240 --> 00:08:58.000
<v Speaker 1>Ah, okay, bit of a hurdle.

183
00:08:57.759 --> 00:09:00.679
<v Speaker 2>A bit, yeah, But then there was lint. Lint was

184
00:09:00.799 --> 00:09:04.519
<v Speaker 2>and still is part of the Android SDK integrated into

185
00:09:04.600 --> 00:09:08.279
<v Speaker 2>Android Studio. Think of it as like a static code analyzer,

186
00:09:08.480 --> 00:09:10.200
<v Speaker 2>but specifically for androids.

187
00:09:09.879 --> 00:09:12.080
<v Speaker 1>So it would warn you about problems exactly.

188
00:09:12.120 --> 00:09:16.320
<v Speaker 2>It would flag potential layout issues automatically, things like deep layouts,

189
00:09:16.320 --> 00:09:19.399
<v Speaker 2>warning you if your view hierarchy was nested too many

190
00:09:19.480 --> 00:09:24.000
<v Speaker 2>levels deep which killed performance, or nested weights in linear layouts,

191
00:09:24.120 --> 00:09:28.279
<v Speaker 2>another notorious performance trap. It also flagged things like useless

192
00:09:28.320 --> 00:09:32.000
<v Speaker 2>parent layouts or useless leaf views that weren't contributing anything

193
00:09:32.519 --> 00:09:34.240
<v Speaker 2>really helpful for keeping UIs lean.

194
00:09:34.480 --> 00:09:35.879
<v Speaker 1>And what if you had a part of the UI

195
00:09:35.960 --> 00:09:39.159
<v Speaker 1>that was complex but maybe wasn't used very often, like

196
00:09:39.200 --> 00:09:41.720
<v Speaker 1>a detailed error message panel. Was there a way to

197
00:09:41.799 --> 00:09:43.200
<v Speaker 1>avoid loading that all the time?

198
00:09:43.320 --> 00:09:45.639
<v Speaker 2>Yes, that's where view stub came in. It was described

199
00:09:45.639 --> 00:09:48.840
<v Speaker 2>as a lazy load mechanism. Basically, it was a placeholder

200
00:09:48.879 --> 00:09:51.679
<v Speaker 2>in your layout. This very lightweight took up almost no

201
00:09:51.840 --> 00:09:55.279
<v Speaker 2>memory or inflation time initially only when you explicitly told

202
00:09:55.320 --> 00:09:57.960
<v Speaker 2>the view stub to inflate, usually in your code, when

203
00:09:58.000 --> 00:10:01.200
<v Speaker 2>that specific UI was actually needed. Would it load the

204
00:10:01.240 --> 00:10:05.159
<v Speaker 2>real more complex layout it was referencing great for reducing

205
00:10:05.240 --> 00:10:08.639
<v Speaker 2>initial screen load time and memory usage for rarely seeing

206
00:10:08.720 --> 00:10:10.080
<v Speaker 2>UI components clever.

207
00:10:10.240 --> 00:10:13.279
<v Speaker 1>Okay, so that's the structure. What about the actual things

208
00:10:13.320 --> 00:10:15.600
<v Speaker 1>the user sees and taps on? The widgets?

209
00:10:15.759 --> 00:10:18.399
<v Speaker 2>Right, the views and widgets. The book mentions all the

210
00:10:18.440 --> 00:10:22.240
<v Speaker 2>common built in ones you'd expect text view for text, button, checkbox,

211
00:10:22.440 --> 00:10:26.639
<v Speaker 2>even things like clock, date, picker, calendar, A whole toolbox

212
00:10:26.679 --> 00:10:28.480
<v Speaker 2>of standard UI elements.

213
00:10:28.080 --> 00:10:30.440
<v Speaker 1>But could you make your own if the standard ones

214
00:10:30.440 --> 00:10:31.000
<v Speaker 1>weren't enough.

215
00:10:31.399 --> 00:10:35.519
<v Speaker 2>Absolutely, customization was key. You could extend an existing widget

216
00:10:35.519 --> 00:10:38.720
<v Speaker 2>to add functionality, or you could create a totally custom

217
00:10:38.799 --> 00:10:41.879
<v Speaker 2>view from scratch by extending the base view class. Doing

218
00:10:41.919 --> 00:10:43.840
<v Speaker 2>that often meant you had to get your hands dirty

219
00:10:43.879 --> 00:10:46.919
<v Speaker 2>overwriting methods like on measure to tell Android how big

220
00:10:46.960 --> 00:10:49.399
<v Speaker 2>your custom view should be, and on draw to actually

221
00:10:49.480 --> 00:10:51.759
<v Speaker 2>draw its appearance on the screen. Using the canvas.

222
00:10:51.480 --> 00:10:54.279
<v Speaker 1>API sounds like more work, but powerful.

223
00:10:54.600 --> 00:10:58.320
<v Speaker 2>Definitely more work, but it gave you complete control. Another

224
00:10:58.320 --> 00:11:02.080
<v Speaker 2>common technique mentioned was creating compound controls. This just meant

225
00:11:02.120 --> 00:11:06.120
<v Speaker 2>grouping several existing controls together into a single reusable component,

226
00:11:06.519 --> 00:11:09.320
<v Speaker 2>like creating a custom search bar widget made up of

227
00:11:09.360 --> 00:11:10.480
<v Speaker 2>a text view and a button.

228
00:11:10.679 --> 00:11:13.279
<v Speaker 1>Okay, so you build a layout, put the widgets in,

229
00:11:13.759 --> 00:11:17.159
<v Speaker 1>but then you need consistent styling, right colors, font sizes.

230
00:11:17.399 --> 00:11:18.240
<v Speaker 1>How is that handled?

231
00:11:18.320 --> 00:11:20.919
<v Speaker 2>That's where styles and themes came in. They were crucial

232
00:11:20.960 --> 00:11:25.000
<v Speaker 2>for maintainability and achieving a consistent look and feel. Styles

233
00:11:25.000 --> 00:11:27.919
<v Speaker 2>were defined in an XML file, usually styles dot XML.

234
00:11:28.320 --> 00:11:31.279
<v Speaker 2>A style was basically a collection of attributes like android

235
00:11:31.279 --> 00:11:34.600
<v Speaker 2>dot layout with android dot background, android dot text color,

236
00:11:34.919 --> 00:11:38.120
<v Speaker 2>android dot text size. You could define a style once

237
00:11:38.320 --> 00:11:40.919
<v Speaker 2>like a CSS class, exactly like a CSS class to

238
00:11:41.000 --> 00:11:45.080
<v Speaker 2>define it once, then apply that style to multiple views button, textview, etc.

239
00:11:45.399 --> 00:11:47.039
<v Speaker 2>In your layouts. So if you needed to change the

240
00:11:47.080 --> 00:11:49.480
<v Speaker 2>standard button color across your app, you just changed it

241
00:11:49.519 --> 00:11:52.039
<v Speaker 2>in the style definition, not on every single button.

242
00:11:52.240 --> 00:11:54.480
<v Speaker 1>Much cleaner in themes, How are they different?

243
00:11:54.759 --> 00:11:57.919
<v Speaker 2>Themes were broader. They applied to an entire activity or

244
00:11:57.960 --> 00:12:02.200
<v Speaker 2>even the whole application, rather than individual views. Themes affected

245
00:12:02.200 --> 00:12:05.679
<v Speaker 2>things like the default appearance of standard widgets or window

246
00:12:05.720 --> 00:12:08.679
<v Speaker 2>attributes like the status bar color, or whether the activity

247
00:12:08.720 --> 00:12:11.120
<v Speaker 2>had a title bar or an action bar. You could

248
00:12:11.159 --> 00:12:13.039
<v Speaker 2>even use a theme to make an activity look like

249
00:12:13.080 --> 00:12:14.960
<v Speaker 2>a floating dialogue box, for instance.

250
00:12:15.200 --> 00:12:17.679
<v Speaker 1>And dealing with different Android versions was a big thing

251
00:12:17.720 --> 00:12:21.039
<v Speaker 1>back then, right with Holo themes the material design coming in.

252
00:12:21.120 --> 00:12:22.240
<v Speaker 1>How did themes handle that?

253
00:12:22.559 --> 00:12:25.799
<v Speaker 2>Yeah, that was a major challenge, the fragmentation. The book

254
00:12:25.799 --> 00:12:30.080
<v Speaker 2>explains how developers used resource qualifiers. You could define different

255
00:12:30.080 --> 00:12:33.759
<v Speaker 2>theme versions and folders like values v eleven for Android

256
00:12:33.799 --> 00:12:37.080
<v Speaker 2>three point zero Honeycomb which introduced the Holo theme, or

257
00:12:37.440 --> 00:12:40.559
<v Speaker 2>values v twenty one for Android five point Oho Lollipop

258
00:12:40.759 --> 00:12:41.759
<v Speaker 2>with material design.

259
00:12:41.919 --> 00:12:44.360
<v Speaker 1>Ah, so the system would automatically pick the right one

260
00:12:44.480 --> 00:12:46.200
<v Speaker 1>based on the device's Android version.

261
00:12:46.559 --> 00:12:50.559
<v Speaker 2>Correct, the system handles selecting the most appropriate resources. But

262
00:12:50.639 --> 00:12:54.279
<v Speaker 2>even more importantly, the app compat library was absolutely essential.

263
00:12:54.480 --> 00:12:58.080
<v Speaker 2>It was a support library from Google that backpoorded newer

264
00:12:58.200 --> 00:13:01.159
<v Speaker 2>UI elements and theme features like the action bar and

265
00:13:01.240 --> 00:13:04.799
<v Speaker 2>material design components to older Android.

266
00:13:04.399 --> 00:13:08.000
<v Speaker 1>Versions, so you could use newer features without dropping support

267
00:13:08.039 --> 00:13:09.639
<v Speaker 1>for older phones exactly.

268
00:13:10.200 --> 00:13:13.320
<v Speaker 2>App Compat was a lifeline for developers trying to provide

269
00:13:13.720 --> 00:13:18.679
<v Speaker 2>a reasonably consistent and modern looking UI across that fragmented landscape.

270
00:13:18.720 --> 00:13:20.679
<v Speaker 2>It smoothed over a lot of the version differences.

271
00:13:20.799 --> 00:13:24.039
<v Speaker 1>Okay, so building on that, the app looks good, it's structured, well,

272
00:13:24.360 --> 00:13:26.399
<v Speaker 1>now it needs to actually respond to the user in

273
00:13:26.480 --> 00:13:30.279
<v Speaker 1>smart ways, provide feedback guide them. What were the standard

274
00:13:30.279 --> 00:13:32.759
<v Speaker 1>ways to handle interaction like menus and alerts.

275
00:13:32.919 --> 00:13:35.600
<v Speaker 2>Right. This is where the user experience really starts to

276
00:13:35.600 --> 00:13:39.440
<v Speaker 2>take shape, making the app feel interactive and intuitive. The

277
00:13:39.480 --> 00:13:43.080
<v Speaker 2>cookbook dies into several key areas here, starting with menu systems.

278
00:13:43.360 --> 00:13:46.440
<v Speaker 2>Menus were and still are a fundamental way to provide

279
00:13:46.480 --> 00:13:47.919
<v Speaker 2>options and actions to the user.

280
00:13:48.080 --> 00:13:50.200
<v Speaker 1>What were the main kinds of menus available back in

281
00:13:50.240 --> 00:13:51.720
<v Speaker 1>twenty sixteen, Well, the main.

282
00:13:51.600 --> 00:13:54.720
<v Speaker 2>One was the options menu. That's the standard menu, typically

283
00:13:54.759 --> 00:13:56.639
<v Speaker 2>appearing in the action bar at the top of the screen.

284
00:13:57.240 --> 00:13:59.960
<v Speaker 2>If there wasn't enough space, items would go into that

285
00:14:00.039 --> 00:14:01.720
<v Speaker 2>familiar three dot overflow menu.

286
00:14:01.799 --> 00:14:03.000
<v Speaker 1>Okay, the standard stuff.

287
00:14:03.120 --> 00:14:07.600
<v Speaker 2>Yeah. Developers used XML attributes like show as action to

288
00:14:07.639 --> 00:14:10.159
<v Speaker 2>suggest whether an item should appear directly in the bar

289
00:14:10.480 --> 00:14:13.720
<v Speaker 2>bedroom or always being the overflow never. Then there was

290
00:14:13.799 --> 00:14:18.480
<v Speaker 2>contextual mode or Contextual Action Mode CM. This was seen

291
00:14:18.480 --> 00:14:21.600
<v Speaker 2>as a big improvement introduced around Android three point zero.

292
00:14:22.000 --> 00:14:24.159
<v Speaker 2>You typically trigger it with a long press on an

293
00:14:24.200 --> 00:14:27.200
<v Speaker 2>item like a list item or some text.

294
00:14:27.039 --> 00:14:28.720
<v Speaker 1>Ah like a right click on desktop.

295
00:14:28.840 --> 00:14:31.080
<v Speaker 2>Exactly like a right click, it would bring up a

296
00:14:31.080 --> 00:14:33.799
<v Speaker 2>temporary action bar at the top with action specific to

297
00:14:33.840 --> 00:14:37.240
<v Speaker 2>the item or items you selected. It supported selecting multiple

298
00:14:37.240 --> 00:14:41.200
<v Speaker 2>items too, for batch actions. Like deleting multiple emails. Way

299
00:14:41.240 --> 00:14:43.279
<v Speaker 2>better than the older floating context menus.

300
00:14:43.320 --> 00:14:45.679
<v Speaker 1>Okay, that sounds useful any other menu types.

301
00:14:45.879 --> 00:14:48.799
<v Speaker 2>There was also the pop up menu. This was simpler,

302
00:14:48.879 --> 00:14:51.320
<v Speaker 2>just a little menu that pops up, often anchored to

303
00:14:51.360 --> 00:14:55.519
<v Speaker 2>a specific view, providing some extra actions. It wasn't necessarily

304
00:14:55.559 --> 00:14:57.960
<v Speaker 2>tied to acting on the view that triggered it, more

305
00:14:58.039 --> 00:15:01.159
<v Speaker 2>like providing related options in nearby, like a spinner, but

306
00:15:01.320 --> 00:15:02.279
<v Speaker 2>in a menu format.

307
00:15:02.519 --> 00:15:06.000
<v Speaker 1>Got it. So beyond menus for explicit actions, how did

308
00:15:06.039 --> 00:15:09.000
<v Speaker 1>apps grab the user's attention or give quick feedback without

309
00:15:09.039 --> 00:15:09.919
<v Speaker 1>being too disruptive?

310
00:15:10.120 --> 00:15:13.279
<v Speaker 2>For that, you had various alerts and notifications. For immediate

311
00:15:13.279 --> 00:15:16.360
<v Speaker 2>physical feedback. Apps could use the vibrator service to make

312
00:15:16.399 --> 00:15:19.639
<v Speaker 2>the phone vibrate simple enough, or play sounds using the

313
00:15:19.679 --> 00:15:23.759
<v Speaker 2>ringtone manager to pla say, the default notification sound. The

314
00:15:23.759 --> 00:15:27.120
<v Speaker 2>book even mentions a newer API twenty three feature set

315
00:15:27.159 --> 00:15:30.360
<v Speaker 2>torch mode to flash the camera light briefly as an alert.

316
00:15:30.679 --> 00:15:32.240
<v Speaker 1>Using the flashlight for alerts.

317
00:15:32.320 --> 00:15:35.120
<v Speaker 2>That's novel, Yeah, a bit unusual, but shows the kind

318
00:15:35.120 --> 00:15:39.080
<v Speaker 2>of low level control you had for quick non blocking messages.

319
00:15:39.440 --> 00:15:41.039
<v Speaker 2>Toasts or the standard toasts.

320
00:15:41.120 --> 00:15:43.720
<v Speaker 1>Right, those little gray boxes that pop up briefly at

321
00:15:43.759 --> 00:15:45.600
<v Speaker 1>the bottom exactly.

322
00:15:45.279 --> 00:15:49.080
<v Speaker 2>They'd show a short text message and then fade away, simple, unobtrusive.

323
00:15:49.360 --> 00:15:52.600
<v Speaker 2>You could even customize their layout if you wanted something fancier.

324
00:15:52.279 --> 00:15:55.519
<v Speaker 1>Than just text, and for messages that needed a user

325
00:15:55.600 --> 00:15:58.039
<v Speaker 1>response like a confirmation.

326
00:15:57.519 --> 00:16:00.720
<v Speaker 2>That's where alert dialogue came in the classic message box.

327
00:16:01.159 --> 00:16:04.120
<v Speaker 2>You could create dialogues with a title, a message, and

328
00:16:04.200 --> 00:16:08.720
<v Speaker 2>up to three standard buttons positive, negative, neutral like yes,

329
00:16:08.759 --> 00:16:11.639
<v Speaker 2>no cancel. You could also add icons or even put

330
00:16:11.639 --> 00:16:15.080
<v Speaker 2>lists inside them single choice lists, multi choice lists, or

331
00:16:15.159 --> 00:16:18.440
<v Speaker 2>embed a completely custom layout if needed. Very flexible.

332
00:16:18.519 --> 00:16:22.039
<v Speaker 1>What about showing progress like if something was loading.

333
00:16:22.200 --> 00:16:25.320
<v Speaker 2>There was progress dialogue. It showed a spinning wheel or

334
00:16:25.320 --> 00:16:29.720
<v Speaker 2>a progress bar, typically indicating loading or some indeterminate task. However,

335
00:16:29.720 --> 00:16:34.000
<v Speaker 2>the cookbook explicitly advised developers to avoid progress dialogue if possible.

336
00:16:34.039 --> 00:16:35.240
<v Speaker 1>Why I avoid it.

337
00:16:35.440 --> 00:16:38.440
<v Speaker 2>Because it was modal. It blocked the user from interacting

338
00:16:38.480 --> 00:16:40.559
<v Speaker 2>with the rest of the app until it was dismissed,

339
00:16:41.080 --> 00:16:43.519
<v Speaker 2>which could be really frustrating if the task took a while.

340
00:16:44.000 --> 00:16:46.720
<v Speaker 2>The recommendation was to integrate a progress bar directly into

341
00:16:46.759 --> 00:16:49.440
<v Speaker 2>your apps layout instead, so the user could still interact

342
00:16:49.480 --> 00:16:51.120
<v Speaker 2>with other parts of the UI. Wall waiting.

343
00:16:51.360 --> 00:16:54.720
<v Speaker 1>That's a key usability point even back then. Okay, so

344
00:16:54.799 --> 00:16:58.559
<v Speaker 1>that's in app alerts. What about the system notifications, the

345
00:16:58.559 --> 00:17:00.879
<v Speaker 1>ones that appear in the notification.

346
00:17:00.320 --> 00:17:04.720
<v Speaker 2>Drawer, Ah notifications. Yeah, super important for engaging users when

347
00:17:04.759 --> 00:17:08.039
<v Speaker 2>the app wasn't in the foreground. Developers built these using

348
00:17:08.079 --> 00:17:12.119
<v Speaker 2>notification compat builder. That compact part signifies it came from

349
00:17:12.160 --> 00:17:16.440
<v Speaker 2>the support library, helping ensure compatibility across different Android versions.

350
00:17:16.720 --> 00:17:19.480
<v Speaker 2>You'd set things like a small icon, a title, the

351
00:17:19.519 --> 00:17:20.799
<v Speaker 2>main content text, and.

352
00:17:20.720 --> 00:17:24.279
<v Speaker 1>Could you add buttons to notifications like reply or archive?

353
00:17:24.720 --> 00:17:27.839
<v Speaker 2>Yes? Absolutely, you could add action buttons using something called

354
00:17:27.920 --> 00:17:31.400
<v Speaker 2>pending intent. A pending intent is basically a token that

355
00:17:31.440 --> 00:17:34.240
<v Speaker 2>you give to the Android system. It wraps an intent

356
00:17:34.480 --> 00:17:36.680
<v Speaker 2>and grants the system permission to send that intent on

357
00:17:36.680 --> 00:17:39.359
<v Speaker 2>your app's behalf at a later time, even if your

358
00:17:39.400 --> 00:17:40.160
<v Speaker 2>app isn't running.

359
00:17:40.559 --> 00:17:42.920
<v Speaker 1>So the notification itself could trigger an action in your

360
00:17:42.920 --> 00:17:44.759
<v Speaker 1>app securely exactly.

361
00:17:45.000 --> 00:17:48.720
<v Speaker 2>It's how notification actions worked. Clicking a reply button might

362
00:17:48.799 --> 00:17:51.559
<v Speaker 2>launch a specific activity in your app, or trigger a

363
00:17:51.559 --> 00:17:55.200
<v Speaker 2>background service to handle the reply. Later Android versions added

364
00:17:55.200 --> 00:17:59.480
<v Speaker 2>more features like expanded notifications. Android four point one plus

365
00:18:00.079 --> 00:18:02.720
<v Speaker 2>could show more content, like a longer text snippet or

366
00:18:02.759 --> 00:18:06.240
<v Speaker 2>an image using set style, and Android five point zero

367
00:18:06.319 --> 00:18:10.559
<v Speaker 2>brought specialized styles like media player notifications with playback controls,

368
00:18:10.839 --> 00:18:13.839
<v Speaker 2>though the book notes this wasn't in the compat library yet,

369
00:18:14.119 --> 00:18:15.960
<v Speaker 2>and also heads up notifications.

370
00:18:16.000 --> 00:18:17.680
<v Speaker 1>Oh those ones that pop up over everything.

371
00:18:17.759 --> 00:18:19.960
<v Speaker 2>Yeah, the really intrusive ones. They appeared on top of

372
00:18:20.000 --> 00:18:22.519
<v Speaker 2>whatever app you were using. They were reserved for high

373
00:18:22.599 --> 00:18:25.920
<v Speaker 2>priority things and required setting priority macs and usually having

374
00:18:25.960 --> 00:18:29.480
<v Speaker 2>a sound or vibration to trigger them. You sparingly definitely.

375
00:18:29.799 --> 00:18:34.119
<v Speaker 1>Okay, so we've got menus, alerts, notifications. What about handling

376
00:18:34.119 --> 00:18:36.480
<v Speaker 1>direct touch on the screen and tapping into all those

377
00:18:36.519 --> 00:18:38.279
<v Speaker 1>sensors phones have, right.

378
00:18:38.119 --> 00:18:41.519
<v Speaker 2>Making the app physically responsive. The book covers touchscreen and

379
00:18:41.599 --> 00:18:45.160
<v Speaker 2>sensors quite well. For the basics simple clicks and long

380
00:18:45.200 --> 00:18:48.759
<v Speaker 2>presses you'd use on click listener and on long click listener.

381
00:18:48.880 --> 00:18:50.960
<v Speaker 2>You can set these up in your Java colon code

382
00:18:51.200 --> 00:18:54.359
<v Speaker 2>or even directly in the XML layout using the Android

383
00:18:54.400 --> 00:18:57.279
<v Speaker 2>dot on click attribute. For simple cases, any of you

384
00:18:57.440 --> 00:18:58.880
<v Speaker 2>could have these listeners.

385
00:18:58.599 --> 00:19:01.799
<v Speaker 1>And for more complex gestures swiping, pinching.

386
00:19:02.359 --> 00:19:07.279
<v Speaker 2>For common gestures like detecting swipes, flings, double taps, single taps,

387
00:19:07.759 --> 00:19:10.880
<v Speaker 2>the gesture detector compact class from the support library was

388
00:19:10.920 --> 00:19:14.279
<v Speaker 2>the way to go. It's simplified detecting these standard motions

389
00:19:14.799 --> 00:19:18.200
<v Speaker 2>for multi touch, specifically pinched to zoom, there was scale

390
00:19:18.240 --> 00:19:21.440
<v Speaker 2>gesture detector. It would track two fingers and provide you

391
00:19:21.480 --> 00:19:23.680
<v Speaker 2>with a scale factor indicating how much the user was

392
00:19:23.720 --> 00:19:26.240
<v Speaker 2>trying to zoom in or out. You'd then use that

393
00:19:26.240 --> 00:19:28.640
<v Speaker 2>factor to resize an image or map for example.

394
00:19:28.759 --> 00:19:32.279
<v Speaker 1>Okay, and that common pattern pulling down to refresh a list.

395
00:19:32.240 --> 00:19:35.000
<v Speaker 2>Ah, yes, swipe to refresh. That was made much easier

396
00:19:35.039 --> 00:19:37.440
<v Speaker 2>with the swipe refreshed layout widget. You just wrap your

397
00:19:37.480 --> 00:19:40.960
<v Speaker 2>list view like a blist view or recycle view inside

398
00:19:40.960 --> 00:19:43.640
<v Speaker 2>this layout, set up a listener and it would handle

399
00:19:43.680 --> 00:19:47.160
<v Speaker 2>detecting the pull gester and showing the standard refresh indicator

400
00:19:47.200 --> 00:19:49.160
<v Speaker 2>for you much less boilerplate code.

401
00:19:49.359 --> 00:19:54.680
<v Speaker 1>Nice. Now beyond the screen, what about sensors, accelerometer, compass.

402
00:19:54.599 --> 00:19:57.039
<v Speaker 2>Yeah, The Android sensor framework opened up a lot of

403
00:19:57.079 --> 00:20:00.799
<v Speaker 2>possibilities for context to wear apps. First, you could query

404
00:20:00.839 --> 00:20:03.839
<v Speaker 2>the sensor manager to see what sensors were actually available

405
00:20:03.880 --> 00:20:08.160
<v Speaker 2>on the specific device accelerometer, gyroscope, light sensor, magnetic field sensor,

406
00:20:08.160 --> 00:20:11.720
<v Speaker 2>proximity sensor, et cetera. Not all devices had all sensors right,

407
00:20:11.799 --> 00:20:15.319
<v Speaker 2>you had to check first definitely. Then to get data,

408
00:20:15.599 --> 00:20:18.720
<v Speaker 2>you'd register a sensor event listener. This listener has a

409
00:20:18.720 --> 00:20:22.480
<v Speaker 2>callback method on sensor changed, which gets called repeatedly by

410
00:20:22.480 --> 00:20:25.400
<v Speaker 2>the system whenever there's a new sensor data. It provides

411
00:20:25.440 --> 00:20:28.200
<v Speaker 2>a sensor event object containing the actual values.

412
00:20:28.319 --> 00:20:29.759
<v Speaker 1>And the cookbook had an example.

413
00:20:30.039 --> 00:20:33.000
<v Speaker 2>It did a really neat one creating a simple compass.

414
00:20:33.440 --> 00:20:35.759
<v Speaker 2>It showed how to get data from both the magnetic

415
00:20:35.759 --> 00:20:39.839
<v Speaker 2>field sensor and the accelerometer. Then you'd use methods like

416
00:20:40.000 --> 00:20:43.480
<v Speaker 2>sensor manager dot get rotation matrix and sensor manager dot

417
00:20:43.519 --> 00:20:47.200
<v Speaker 2>get orientation to combine that data and calculate the device's

418
00:20:47.240 --> 00:20:49.599
<v Speaker 2>orientation relative to magnetic.

419
00:20:49.160 --> 00:20:52.279
<v Speaker 1>North and use that to rotate a compass needle image.

420
00:20:52.440 --> 00:20:55.359
<v Speaker 2>Exactly, you'd update the rotation of an image view showing

421
00:20:55.400 --> 00:20:58.720
<v Speaker 2>a compass needle based on the calculated orientation angles. A

422
00:20:58.720 --> 00:21:00.720
<v Speaker 2>great practical example of you use using sensor.

423
00:21:00.519 --> 00:21:05.640
<v Speaker 1>Fusion cool and finally just basic device orientation portrait versus landscape.

424
00:21:05.799 --> 00:21:08.720
<v Speaker 2>Yep. You can easily check the current configuration for configuration

425
00:21:08.839 --> 00:21:13.279
<v Speaker 2>dot orientation landscape or orientation portrait. The book also mentioned

426
00:21:13.400 --> 00:21:16.279
<v Speaker 2>using Android dot config changes in the manifest to prevent

427
00:21:16.319 --> 00:21:20.799
<v Speaker 2>the default activity recreation on orientation changes, but strongly cautioned

428
00:21:20.839 --> 00:21:23.319
<v Speaker 2>that this was usually not the right approach. It was

429
00:21:23.359 --> 00:21:26.119
<v Speaker 2>better to handle the recreation properly with state.

430
00:21:25.880 --> 00:21:29.240
<v Speaker 1>Saving right avoiding the life cycle rather than handling it.

431
00:21:29.599 --> 00:21:30.000
<v Speaker 2>Got it.

432
00:21:30.759 --> 00:21:33.240
<v Speaker 1>Okay, we've covered a huge amount on the UI and interaction,

433
00:21:33.839 --> 00:21:37.400
<v Speaker 1>but apps need data and they need to connect. This

434
00:21:37.599 --> 00:21:41.279
<v Speaker 1>next bit seems crucial. How did developers manage data storage

435
00:21:41.279 --> 00:21:44.880
<v Speaker 1>and network communication back in twenty sixteen? It sounds complex,

436
00:21:45.039 --> 00:21:46.200
<v Speaker 1>It really was, and.

437
00:21:46.200 --> 00:21:49.079
<v Speaker 2>This segment highlights the challenge of doing it efficiently and

438
00:21:49.119 --> 00:21:52.599
<v Speaker 2>reliably on mobile and reads the question how do these

439
00:21:52.640 --> 00:21:56.319
<v Speaker 2>cookbook solutions scale? The book lays out the main data

440
00:21:56.319 --> 00:21:57.640
<v Speaker 2>storage options available.

441
00:21:57.680 --> 00:21:58.559
<v Speaker 1>Then what were they?

442
00:21:58.599 --> 00:22:02.160
<v Speaker 2>First? You had shared preferences, super simple key value storage

443
00:22:02.200 --> 00:22:05.559
<v Speaker 2>for private primitive data I think user settings, maybe log

444
00:22:05.599 --> 00:22:07.680
<v Speaker 2>in token, easy to use for small bits.

445
00:22:07.519 --> 00:22:10.000
<v Speaker 1>Of data, okay, like a little settings file exactly.

446
00:22:10.519 --> 00:22:14.400
<v Speaker 2>Then internal storage. This was for saving private files directly

447
00:22:14.440 --> 00:22:18.200
<v Speaker 2>to the device's internal memory. Other apps couldn't access these files,

448
00:22:18.440 --> 00:22:21.519
<v Speaker 2>and they got deleted automatically if the user uninstalled your app.

449
00:22:22.000 --> 00:22:26.359
<v Speaker 2>The downside usually less space available compared to external storage,

450
00:22:26.480 --> 00:22:27.480
<v Speaker 2>but it's always there.

451
00:22:27.359 --> 00:22:29.720
<v Speaker 1>And external storage the SD card usually.

452
00:22:29.599 --> 00:22:32.880
<v Speaker 2>Right or simulated external storage. This was for files you

453
00:22:32.960 --> 00:22:36.039
<v Speaker 2>might want the user to access directly, or larger files

454
00:22:36.119 --> 00:22:39.880
<v Speaker 2>could be public or private within your app specific external folder.

455
00:22:40.480 --> 00:22:44.200
<v Speaker 2>The big caveat external storage might not always be available.

456
00:22:44.960 --> 00:22:47.559
<v Speaker 2>If the user mounted the device as USD storage on

457
00:22:47.640 --> 00:22:50.839
<v Speaker 2>a computer or move the SD card, your app couldn't

458
00:22:50.880 --> 00:22:52.680
<v Speaker 2>access it. You always had to check its.

459
00:22:52.599 --> 00:22:54.319
<v Speaker 1>State permissions needed for that too.

460
00:22:54.359 --> 00:22:57.519
<v Speaker 2>I bet write external storage and re external storage.

461
00:22:57.599 --> 00:23:01.359
<v Speaker 1>Okay, what about more structured data, not just key value pairs.

462
00:23:01.599 --> 00:23:04.880
<v Speaker 2>That's where squad database came in. Android has built in

463
00:23:04.960 --> 00:23:08.759
<v Speaker 2>support for Squily. It provided a private relational database for

464
00:23:08.799 --> 00:23:12.400
<v Speaker 2>your app. Great for storing lots of structured data, contacts, inventory,

465
00:23:12.440 --> 00:23:15.480
<v Speaker 2>game scores, anything complex. You could even expose this data

466
00:23:15.519 --> 00:23:18.759
<v Speaker 2>to other apps securely using something called the content provider,

467
00:23:19.039 --> 00:23:21.079
<v Speaker 2>but mostly it was for internal app data.

468
00:23:21.119 --> 00:23:22.880
<v Speaker 1>The standard for local databases then.

469
00:23:23.079 --> 00:23:27.319
<v Speaker 2>Yeah. Lastly, lastly, the book broadly mentions cloud storage, basically

470
00:23:27.440 --> 00:23:30.119
<v Speaker 2>saving data off the device, either to your own private

471
00:23:30.160 --> 00:23:32.880
<v Speaker 2>servers or using third party cloud service providers.

472
00:23:33.240 --> 00:23:37.000
<v Speaker 1>Gotcha, So focusing on files for a moment, how did

473
00:23:37.039 --> 00:23:41.440
<v Speaker 1>developers actually read and write files? Maybe manage temporary data?

474
00:23:41.440 --> 00:23:45.079
<v Speaker 2>Standard java file io, mostly using file input stream. File

475
00:23:45.119 --> 00:23:48.319
<v Speaker 2>input stream often wrapped with buffer reader or print writer

476
00:23:48.519 --> 00:23:52.279
<v Speaker 2>for text files. The cookbook showed examples for both internal

477
00:23:52.359 --> 00:23:55.720
<v Speaker 2>and external storage. For temporary data, there was a dedicated

478
00:23:55.759 --> 00:23:59.319
<v Speaker 2>cash directory you could get via getcash dear. The idea

479
00:23:59.400 --> 00:24:02.799
<v Speaker 2>was you put temporary files here, and the Android system

480
00:24:02.920 --> 00:24:05.200
<v Speaker 2>was free to delete these files if the device started

481
00:24:05.240 --> 00:24:07.960
<v Speaker 2>running low on storage, so you couldn't rely on cash

482
00:24:08.000 --> 00:24:10.039
<v Speaker 2>files persisting important distinction.

483
00:24:10.400 --> 00:24:13.160
<v Speaker 1>What about including files directly in the app package, like

484
00:24:13.279 --> 00:24:15.200
<v Speaker 1>audio clips or maybe some data files?

485
00:24:15.200 --> 00:24:16.880
<v Speaker 2>Two main ways for that. You could put files in

486
00:24:16.880 --> 00:24:19.880
<v Speaker 2>the reservo folder. These were treated like other resources. They

487
00:24:19.920 --> 00:24:23.680
<v Speaker 2>got a resource ID or brought up idio. Android verified

488
00:24:23.680 --> 00:24:25.839
<v Speaker 2>the existed a compile time, and you access them via

489
00:24:25.839 --> 00:24:28.680
<v Speaker 2>that ID. Good for things like media files okay, and

490
00:24:28.720 --> 00:24:31.440
<v Speaker 2>the other way the assets folder. Files placed here were

491
00:24:31.440 --> 00:24:34.240
<v Speaker 2>compiled into the APK as well, but they didn't get

492
00:24:34.240 --> 00:24:37.519
<v Speaker 2>resource IDs. You access them more like a traditional filesystem,

493
00:24:37.799 --> 00:24:41.000
<v Speaker 2>using their file names via the asset manager. This was

494
00:24:41.119 --> 00:24:44.400
<v Speaker 2>useful if you needed to access files by dynamically generated names,

495
00:24:44.839 --> 00:24:47.559
<v Speaker 2>or if you were using a library that expected filepaths

496
00:24:47.599 --> 00:24:50.640
<v Speaker 2>instead of resource IDs. The trade off was less compile

497
00:24:50.680 --> 00:24:51.319
<v Speaker 2>time safety.

498
00:24:51.519 --> 00:24:54.640
<v Speaker 1>Right. Okay, let's dive deeper into secollite. That seems like

499
00:24:54.680 --> 00:24:58.279
<v Speaker 1>a core piece. How did the cookbook approach actually using

500
00:24:58.279 --> 00:25:01.160
<v Speaker 1>the database, creating adding data?

501
00:25:01.720 --> 00:25:06.519
<v Speaker 2>It focused heavily on the practical cr rout operations create, read, update, delete.

502
00:25:07.160 --> 00:25:09.279
<v Speaker 2>The main tool for managing the database was the slee

503
00:25:09.319 --> 00:25:10.440
<v Speaker 2>out open helper class.

504
00:25:10.480 --> 00:25:12.359
<v Speaker 1>That's quite open helper It's subclass.

505
00:25:12.400 --> 00:25:15.400
<v Speaker 2>This helper it had methods like on create, where you'd

506
00:25:15.440 --> 00:25:18.920
<v Speaker 2>define your initial database schema that create table statements, and

507
00:25:19.000 --> 00:25:22.079
<v Speaker 2>on upgrade, where you'd put logic to handle migrating data

508
00:25:22.119 --> 00:25:24.240
<v Speaker 2>if you change your schema in a future app update.

509
00:25:24.599 --> 00:25:27.920
<v Speaker 2>This was managed by incrementing the database version constant ah.

510
00:25:28.079 --> 00:25:30.039
<v Speaker 1>Managing those schema changes is always.

511
00:25:29.799 --> 00:25:34.200
<v Speaker 2>Tricky, always. The helper simplified it somewhat. The cookbook used

512
00:25:34.200 --> 00:25:37.599
<v Speaker 2>a simple dictionary database example words and definitions to show

513
00:25:37.599 --> 00:25:41.319
<v Speaker 2>how to insert new words, query for definitions, update entries,

514
00:25:41.759 --> 00:25:44.279
<v Speaker 2>and delete them using methods on the squad day database

515
00:25:44.319 --> 00:25:47.079
<v Speaker 2>object you got from the helper. It also pointed out

516
00:25:47.119 --> 00:25:51.839
<v Speaker 2>an important convention, including an integer primary key column named ID.

517
00:25:52.480 --> 00:25:56.519
<v Speaker 2>This wasn't strictly required by Scorelight, but many Android framework classes,

518
00:25:56.680 --> 00:26:00.200
<v Speaker 2>especially UI adapters like simple cursor adapter expected it, so

519
00:26:00.240 --> 00:26:01.279
<v Speaker 2>it was best practice.

520
00:26:01.440 --> 00:26:04.599
<v Speaker 1>Good tip. Now, database queries can be slow. Doing that

521
00:26:04.680 --> 00:26:07.799
<v Speaker 1>on the main UI thread is bad right leads to freezes.

522
00:26:07.559 --> 00:26:10.319
<v Speaker 2>Absolutely a cardinal sin and and or development. Blocking the

523
00:26:10.319 --> 00:26:13.880
<v Speaker 2>main thread leads to sluggishness and potentially the dreaded application

524
00:26:13.960 --> 00:26:15.799
<v Speaker 2>not responding anur dialogue.

525
00:26:15.799 --> 00:26:19.319
<v Speaker 1>So how did they handle background database access cleanly? Back then, the.

526
00:26:19.279 --> 00:26:22.079
<v Speaker 2>Recommended approach in the cookbook, especially for loading data to

527
00:26:22.079 --> 00:26:26.559
<v Speaker 2>display in the UI, was using loaders, yes, specifically cursor

528
00:26:26.680 --> 00:26:30.319
<v Speaker 2>loader for database queries. Loaders were part of the Android

529
00:26:30.319 --> 00:26:34.559
<v Speaker 2>framework designed to simplify asynchronous data loading. The big benefits

530
00:26:34.559 --> 00:26:39.240
<v Speaker 2>were they automatically performed the database query on a background thread,

531
00:26:39.480 --> 00:26:42.440
<v Speaker 2>so the UI thread wasn't blocked, and if you were

532
00:26:42.480 --> 00:26:45.440
<v Speaker 2>using them with a content provider, they could automatically monitor

533
00:26:45.480 --> 00:26:48.599
<v Speaker 2>the underlying data source for changes and reload the data

534
00:26:48.599 --> 00:26:51.880
<v Speaker 2>to update the UI, although without a content provider you

535
00:26:51.960 --> 00:26:53.799
<v Speaker 2>might need to manually trigger a reload.

536
00:26:54.039 --> 00:26:56.720
<v Speaker 1>So they handled the background thread and delivering results back

537
00:26:56.720 --> 00:26:58.160
<v Speaker 1>to the UI thread exactly.

538
00:26:58.319 --> 00:27:01.960
<v Speaker 2>You'd implement loadermanager dot loader callbacks. The on create loader

539
00:27:02.000 --> 00:27:05.119
<v Speaker 2>method would create and return your cursor latter specifying the query.

540
00:27:05.440 --> 00:27:08.039
<v Speaker 2>The loader did the work in the background. Then the

541
00:27:08.079 --> 00:27:11.559
<v Speaker 2>onload finished callback, which ran on the UI thread, would

542
00:27:11.599 --> 00:27:14.519
<v Speaker 2>deliver the resulting data a cursor in this case, ready

543
00:27:14.519 --> 00:27:17.359
<v Speaker 2>for you to update your UI adapter. It abstracted away

544
00:27:17.359 --> 00:27:18.640
<v Speaker 2>a lot of the threading complexity.

545
00:27:18.799 --> 00:27:22.279
<v Speaker 1>Okay, that sounds much better than raw threads shifting gears.

546
00:27:22.319 --> 00:27:25.920
<v Speaker 1>Now to communication off the device, what about interacting with

547
00:27:26.000 --> 00:27:27.920
<v Speaker 1>phone features like calls and SMS.

548
00:27:28.200 --> 00:27:31.640
<v Speaker 2>Apps could definitely do that, though it required specific permissions.

549
00:27:32.400 --> 00:27:35.039
<v Speaker 2>For making a phone call, you'd use an intent with

550
00:27:35.119 --> 00:27:37.559
<v Speaker 2>the ax that you would call action and the phone number.

551
00:27:37.799 --> 00:27:40.359
<v Speaker 2>Pretty straightforward, but needed the gellphone permission.

552
00:27:40.440 --> 00:27:43.599
<v Speaker 1>And could you listen for call events like know when

553
00:27:43.599 --> 00:27:44.440
<v Speaker 1>a call ends.

554
00:27:44.640 --> 00:27:47.720
<v Speaker 2>Yes, you could create a phone state listener and register

555
00:27:47.799 --> 00:27:51.440
<v Speaker 2>it with the Telephony Manager. This listener had callbacks for

556
00:27:51.559 --> 00:27:55.920
<v Speaker 2>various state changes, including running off hook and IDOL call ended.

557
00:27:56.160 --> 00:27:56.519
<v Speaker 1>Okay.

558
00:27:56.920 --> 00:28:00.640
<v Speaker 2>Sending SMS for SMS, you'd use the SIMS manager get

559
00:28:00.680 --> 00:28:03.880
<v Speaker 2>the default instance, then call, send text message, passing the

560
00:28:03.920 --> 00:28:08.240
<v Speaker 2>destination number, message body, etc. Required the send SMS permission.

561
00:28:08.480 --> 00:28:11.480
<v Speaker 2>The book even mentioned handling long messages using divide.

562
00:28:11.119 --> 00:28:12.759
<v Speaker 1>Message and receiving SMS.

563
00:28:13.000 --> 00:28:15.799
<v Speaker 2>That involves setting up a broadcast receiver You'd declare it

564
00:28:15.799 --> 00:28:18.319
<v Speaker 2>in your manifest with an intent filter for the Android

565
00:28:18.359 --> 00:28:22.240
<v Speaker 2>Dot provider telefany dot SMS received action and request the

566
00:28:22.279 --> 00:28:25.759
<v Speaker 2>receives MS permission. When an SMS arrived, your receiver's on

567
00:28:25.920 --> 00:28:29.599
<v Speaker 2>receive method would be called with the message details. Pretty

568
00:28:29.599 --> 00:28:32.000
<v Speaker 2>low level access to core functions definitely okay.

569
00:28:32.000 --> 00:28:35.039
<v Speaker 1>Broader network stuff displaying web content or checking if the

570
00:28:35.079 --> 00:28:36.160
<v Speaker 1>phone is online.

571
00:28:36.319 --> 00:28:39.880
<v Speaker 2>Web and network communication yeah. Essential for just displaying web

572
00:28:39.920 --> 00:28:42.759
<v Speaker 2>pages within your app. WebView is the component you could

573
00:28:42.759 --> 00:28:46.880
<v Speaker 2>load URLs, html, strings, whatever. A key part was using

574
00:28:46.880 --> 00:28:49.880
<v Speaker 2>a WebView client. By setting your own client, you could

575
00:28:49.920 --> 00:28:54.200
<v Speaker 2>intercept page navigation. For example, you could force links clicked

576
00:28:54.200 --> 00:28:57.119
<v Speaker 2>within the WebView to open in the same WebView rather

577
00:28:57.160 --> 00:28:59.759
<v Speaker 2>than launching an external browser, keeping the user within your

578
00:28:59.759 --> 00:29:04.000
<v Speaker 2>app up. You could even restrict navigation to only specific domains.

579
00:29:03.759 --> 00:29:08.279
<v Speaker 1>Making it feel more integrated. And just checking connectivity yep, you'd.

580
00:29:08.160 --> 00:29:11.000
<v Speaker 2>Use the Connectivity Manager system service. You could get the

581
00:29:11.039 --> 00:29:13.839
<v Speaker 2>active network info object and check if it was connected

582
00:29:13.880 --> 00:29:17.319
<v Speaker 2>and its type Wi Fi mobile. This required the Internet

583
00:29:17.359 --> 00:29:21.440
<v Speaker 2>and access network state permissions, crucial before attempting any network

584
00:29:21.480 --> 00:29:22.680
<v Speaker 2>operation right now.

585
00:29:22.720 --> 00:29:25.559
<v Speaker 1>The cookbook mentioned a library called Volley as a new

586
00:29:25.599 --> 00:29:28.799
<v Speaker 1>option back in twenty sixteen for network requests, What was

587
00:29:28.799 --> 00:29:29.680
<v Speaker 1>the deal with Volley?

588
00:29:30.119 --> 00:29:33.279
<v Speaker 2>Ah? Volley. Yes, it was introduced by Google and positioned

589
00:29:33.319 --> 00:29:36.400
<v Speaker 2>as a simpler way to handle common network operations compared

590
00:29:36.440 --> 00:29:40.359
<v Speaker 2>to using HTTPURLA connection directly, which involved a lot of

591
00:29:40.359 --> 00:29:41.079
<v Speaker 2>boil play.

592
00:29:40.960 --> 00:29:43.319
<v Speaker 1>Code, so it simplified things it did.

593
00:29:43.759 --> 00:29:47.519
<v Speaker 2>It managed a request queue and a threadpool defaulting to

594
00:29:47.559 --> 00:29:51.920
<v Speaker 2>four threads, automatically handled basic response caching to disc transparently,

595
00:29:52.359 --> 00:29:54.559
<v Speaker 2>and even allowed setting priorities for requests.

596
00:29:54.799 --> 00:29:56.359
<v Speaker 1>Sounds good? What was it best for?

597
00:29:57.359 --> 00:29:59.960
<v Speaker 2>The book highlights that Volley really shown for making law?

598
00:30:00.000 --> 00:30:04.519
<v Speaker 2>What's small network requests efficiently? Think fetching Jason data for

599
00:30:04.559 --> 00:30:08.319
<v Speaker 2>a list or downloading images as a user scrolls. It's

600
00:30:08.359 --> 00:30:12.079
<v Speaker 2>built in support for string Jason and image requests made

601
00:30:12.119 --> 00:30:13.799
<v Speaker 2>these common tasks much easier.

602
00:30:13.960 --> 00:30:16.839
<v Speaker 1>So what were the downsides? The limitations?

603
00:30:16.920 --> 00:30:20.039
<v Speaker 2>The big one mentioned was that Volley was explicitly not

604
00:30:20.160 --> 00:30:23.960
<v Speaker 2>recommended for large downloads or streaming operations. Why not because

605
00:30:24.000 --> 00:30:27.200
<v Speaker 2>it processed and parsed the entire response in memory. Trying

606
00:30:27.200 --> 00:30:29.599
<v Speaker 2>to download a huge file or stream video with Volley

607
00:30:29.599 --> 00:30:32.039
<v Speaker 2>would likely lead to out of memory air crashes. It

608
00:30:32.119 --> 00:30:34.640
<v Speaker 2>just wasn't designed for that. It also had mechanisms for

609
00:30:34.720 --> 00:30:37.880
<v Speaker 2>canceling requests using tags, which was important to avoid wasting

610
00:30:37.880 --> 00:30:40.039
<v Speaker 2>bandwidth if the user navigated away.

611
00:30:40.160 --> 00:30:42.640
<v Speaker 1>So a great tool for specific use cases, but not

612
00:30:42.799 --> 00:30:47.799
<v Speaker 1>a silver bullet for all networking. That's a really important insight. Okay,

613
00:30:47.799 --> 00:30:51.200
<v Speaker 1>we've covered data and connectivity. Now for the final stretch

614
00:30:51.680 --> 00:30:54.880
<v Speaker 1>getting the app ready for the real world, polishing it,

615
00:30:55.119 --> 00:30:58.319
<v Speaker 1>maybe connecting to back end services. What did the cookbook

616
00:30:58.359 --> 00:30:59.519
<v Speaker 1>say about app readiness?

617
00:30:59.720 --> 00:31:02.200
<v Speaker 2>Yeah, and this section really touches on some critical aspects

618
00:31:02.200 --> 00:31:04.720
<v Speaker 2>and it raises that question again, how much of this

619
00:31:04.759 --> 00:31:08.160
<v Speaker 2>twenty sixteen wisdom still applies directly and where have things

620
00:31:08.200 --> 00:31:11.680
<v Speaker 2>fundamentally shifted. One huge shift discussed was the Android six

621
00:31:11.759 --> 00:31:13.440
<v Speaker 2>point zero run time permission.

622
00:31:13.000 --> 00:31:15.640
<v Speaker 1>Model, Right, that was a massive change. Before that, you

623
00:31:15.759 --> 00:31:18.559
<v Speaker 1>just accepted all permissions when installing the app, didn't you exactly?

624
00:31:18.559 --> 00:31:20.480
<v Speaker 2>It was all or nothing. If you didn't like one

625
00:31:20.480 --> 00:31:22.920
<v Speaker 2>permission and app asked for, your only choice was to

626
00:31:22.960 --> 00:31:26.519
<v Speaker 2>not install it. Android six point zero API twenty three

627
00:31:26.640 --> 00:31:29.839
<v Speaker 2>change that completely. Users could now grant or deny permissions

628
00:31:29.839 --> 00:31:32.519
<v Speaker 2>individually at the time the app actually needed them, not

629
00:31:32.720 --> 00:31:36.599
<v Speaker 2>upfronted installation, and they could even revoke permissions later through

630
00:31:36.640 --> 00:31:37.599
<v Speaker 2>the system settings.

631
00:31:37.920 --> 00:31:40.519
<v Speaker 1>Huge win for user privacy and control, But what did

632
00:31:40.559 --> 00:31:41.720
<v Speaker 1>it mean for developers?

633
00:31:41.960 --> 00:31:45.880
<v Speaker 2>It meant a significant code change. Developers now had to

634
00:31:45.920 --> 00:31:49.680
<v Speaker 2>explicitly check if they had a permission using check self permission.

635
00:31:50.359 --> 00:31:52.799
<v Speaker 2>If not, they often needed to show some rationale to

636
00:31:52.839 --> 00:31:55.880
<v Speaker 2>the user explaining why the permission was needed. That was

637
00:31:55.880 --> 00:31:59.119
<v Speaker 2>should show request permission rationale, and then they had to

638
00:31:59.119 --> 00:32:02.759
<v Speaker 2>actually request the prom mission using request permissions and handle

639
00:32:02.799 --> 00:32:05.799
<v Speaker 2>the user's response grant or deny in a callback.

640
00:32:06.119 --> 00:32:08.640
<v Speaker 1>So a lot more interactive permission handling needed.

641
00:32:08.799 --> 00:32:11.559
<v Speaker 2>Definitely. It forced developers to be more thoughtful about the

642
00:32:11.559 --> 00:32:14.680
<v Speaker 2>permissions they requested and when they requested them. A big

643
00:32:14.720 --> 00:32:18.200
<v Speaker 2>step change, but only affected apps running on Android six

644
00:32:18.279 --> 00:32:21.319
<v Speaker 2>point zero plus devices targeting that EPI level or higher.

645
00:32:21.519 --> 00:32:25.480
<v Speaker 1>Okay, what about tasks that needed to run periodically, maybe

646
00:32:25.559 --> 00:32:28.640
<v Speaker 1>even when the app wasn't running, like checking for updates

647
00:32:28.640 --> 00:32:29.440
<v Speaker 1>every few hours.

648
00:32:29.559 --> 00:32:32.079
<v Speaker 2>That was the domain of the alarm manager. You'd use

649
00:32:32.119 --> 00:32:33.920
<v Speaker 2>it to schedule your app to be woken up at

650
00:32:33.960 --> 00:32:37.799
<v Speaker 2>specific times or intervals to perform tasks. The key benefit

651
00:32:37.880 --> 00:32:40.680
<v Speaker 2>was that the OS managed the scheduling. Your app didn't

652
00:32:40.680 --> 00:32:43.839
<v Speaker 2>need to be constantly running in the background, consuming resources.

653
00:32:44.039 --> 00:32:46.640
<v Speaker 2>Just to wake up. Occasionally the OS would wake it

654
00:32:46.720 --> 00:32:48.680
<v Speaker 2>up via intent when the alarm fire.

655
00:32:49.000 --> 00:32:50.440
<v Speaker 1>What kinds of alarms were there?

656
00:32:50.640 --> 00:32:54.160
<v Speaker 2>There were different types based on the clock used. OURTC

657
00:32:54.359 --> 00:32:57.799
<v Speaker 2>used the real time clock wall clock time, while elapsed

658
00:32:57.880 --> 00:33:00.559
<v Speaker 2>real time use the time since the divis I booted,

659
00:33:00.920 --> 00:33:03.279
<v Speaker 2>and there were wake up versions of both which would

660
00:33:03.279 --> 00:33:05.519
<v Speaker 2>actually wake the device CPU if it was asleep when

661
00:33:05.559 --> 00:33:08.480
<v Speaker 2>the alarm fired. Non wake up alarms would only fire

662
00:33:08.519 --> 00:33:10.400
<v Speaker 2>the next time the device woke up for some.

663
00:33:10.279 --> 00:33:12.799
<v Speaker 1>Other reason, and the cookbook had best practices.

664
00:33:13.000 --> 00:33:16.160
<v Speaker 2>Yes, keep alarms in frequent, avoid using wake up alarms

665
00:33:16.240 --> 00:33:20.039
<v Speaker 2>unless absolutely necessary to conserve battery, and use inexact timing

666
00:33:20.079 --> 00:33:23.079
<v Speaker 2>where possible to allow the system to bash alarms together

667
00:33:23.440 --> 00:33:24.880
<v Speaker 2>again for battery efficiency.

668
00:33:25.000 --> 00:33:26.640
<v Speaker 1>Did alarm survive reboots?

669
00:33:26.960 --> 00:33:31.039
<v Speaker 2>Crucially, no alarm manager alarms were cleared when the device rebooted.

670
00:33:31.440 --> 00:33:34.240
<v Speaker 2>If your app needed persistent scheduled tasks, it had to

671
00:33:34.279 --> 00:33:36.839
<v Speaker 2>include a broadcast receiver that listened for the action boot,

672
00:33:36.920 --> 00:33:40.480
<v Speaker 2>completed broadcast, and reschedule its alarms every time the device

673
00:33:40.519 --> 00:33:42.119
<v Speaker 2>started up. A common gotcha.

674
00:33:42.279 --> 00:33:45.640
<v Speaker 1>Ah Okay, now what about that fundamental problem of doing

675
00:33:45.759 --> 00:33:49.160
<v Speaker 1>long running work without freezing the UI we mentioned loaders

676
00:33:49.160 --> 00:33:51.759
<v Speaker 1>for data, But what about other background tasks?

677
00:33:52.240 --> 00:33:55.000
<v Speaker 2>The classic solution, presented in a twenty sixteen cookbook was

678
00:33:55.119 --> 00:33:56.880
<v Speaker 2>acing task Acing task.

679
00:33:57.359 --> 00:33:59.559
<v Speaker 1>Still hear about that one, often not in a good way.

680
00:33:59.720 --> 00:34:02.920
<v Speaker 2>Yeah, yeah, it has a mixed reputation now, But back

681
00:34:02.960 --> 00:34:05.920
<v Speaker 2>then it was a standard, relatively simple way to handle

682
00:34:05.920 --> 00:34:08.800
<v Speaker 2>background work with UI updates. The problem it solves was

683
00:34:08.880 --> 00:34:12.800
<v Speaker 2>clear doing network requests, heavy calculations, or anything slow on

684
00:34:12.840 --> 00:34:15.960
<v Speaker 2>the main UI thread caused the app to hang, leading

685
00:34:15.960 --> 00:34:19.159
<v Speaker 2>to an RS. The rules were simple, don't block the

686
00:34:19.199 --> 00:34:22.199
<v Speaker 2>main thread, do all UI updates on the main thread.

687
00:34:22.519 --> 00:34:24.280
<v Speaker 1>So how did acy task help?

688
00:34:24.639 --> 00:34:27.400
<v Speaker 2>It provided a simple structure. You'd override do end background,

689
00:34:27.440 --> 00:34:30.000
<v Speaker 2>which ran on a background worker thread. That's where you

690
00:34:30.000 --> 00:34:33.199
<v Speaker 2>put your long running code. When doing background finished, it

691
00:34:33.199 --> 00:34:37.159
<v Speaker 2>could return a result. Then on post execute, which automatically

692
00:34:37.239 --> 00:34:39.960
<v Speaker 2>ran back on the main UI thread, received that result,

693
00:34:40.119 --> 00:34:42.480
<v Speaker 2>allowing you to safely update your UI like showing the

694
00:34:42.519 --> 00:34:45.519
<v Speaker 2>downloaded data or hiding a progress bar. It also had

695
00:34:45.599 --> 00:34:48.920
<v Speaker 2>on pre execute UI thread before and on progress update

696
00:34:49.079 --> 00:34:50.320
<v Speaker 2>UI thread for progress.

697
00:34:50.480 --> 00:34:54.119
<v Speaker 1>Sounds straightforward enough, What were the catches? Why the bad reputation? Now?

698
00:34:54.320 --> 00:34:56.960
<v Speaker 2>The main issue hinted at even in the cookbook was

699
00:34:57.000 --> 00:34:59.920
<v Speaker 2>its type coupling with the activity or fragment that started it.

700
00:35:01.000 --> 00:35:04.320
<v Speaker 2>If you started an acing task from an activity and

701
00:35:04.360 --> 00:35:08.920
<v Speaker 2>the user rotated the screen, destroying and recreating the activity

702
00:35:09.199 --> 00:35:12.519
<v Speaker 2>before the task finished, uh oh yeah, the acing task

703
00:35:12.559 --> 00:35:15.880
<v Speaker 2>might hold an implicit reference to the old destroyed activity context.

704
00:35:16.239 --> 00:35:18.400
<v Speaker 2>This could lead to memory leaks, and if the task

705
00:35:18.480 --> 00:35:21.159
<v Speaker 2>tried to update the UI on post execute, it could

706
00:35:21.159 --> 00:35:23.880
<v Speaker 2>crash because the activity was trying to update didn't exist anymore,

707
00:35:24.199 --> 00:35:26.400
<v Speaker 2>or it updated the wrong instance it created.

708
00:35:26.440 --> 00:35:31.199
<v Speaker 1>These orphan tasks so convenient, but fragile if not handled

709
00:35:31.320 --> 00:35:32.000
<v Speaker 1>very carefully.

710
00:35:32.000 --> 00:35:35.440
<v Speaker 2>Extremely That's why the book suggested maybe using it with fragments,

711
00:35:35.519 --> 00:35:40.159
<v Speaker 2>specifically retained fragments or loaders as potentially safer alternatives for

712
00:35:40.199 --> 00:35:43.800
<v Speaker 2>handling background tasks tied to UI life cycles. Modern Android

713
00:35:43.920 --> 00:35:47.159
<v Speaker 2>uses core routines, RX Java or work Manager, which handle

714
00:35:47.199 --> 00:35:48.639
<v Speaker 2>life cycles much more elegantly.

715
00:35:48.719 --> 00:35:52.480
<v Speaker 1>Makes sense. What about other advanced features voice input, push messages.

716
00:35:52.719 --> 00:35:55.880
<v Speaker 2>Yeah, the cookbook touched on those two. Speech recognition was

717
00:35:55.920 --> 00:35:59.360
<v Speaker 2>possible using the Google Speed service available since Android two

718
00:35:59.360 --> 00:36:02.239
<v Speaker 2>point two ap eight. You'd launched an intent to start

719
00:36:02.239 --> 00:36:05.960
<v Speaker 2>the voice recognizer and get the results back. For push notifications,

720
00:36:06.079 --> 00:36:09.119
<v Speaker 2>the standard back then was Google Cloud Messaging GCM.

721
00:36:09.320 --> 00:36:12.280
<v Speaker 1>GCM before FCM, firebased Cloud Messaging.

722
00:36:12.000 --> 00:36:15.400
<v Speaker 2>Exactly, GCM was the predecessor. The architecture involved three parts,

723
00:36:16.119 --> 00:36:19.880
<v Speaker 2>your application server, Google's GCM servers, and the Android device

724
00:36:19.960 --> 00:36:23.239
<v Speaker 2>running your app. The flow was your app registers with

725
00:36:23.320 --> 00:36:26.760
<v Speaker 2>GCM servers to get a unique device registration token. Your

726
00:36:26.760 --> 00:36:29.320
<v Speaker 2>app sends this token to your back end server. When

727
00:36:29.320 --> 00:36:31.519
<v Speaker 2>your server wants to send a push message, it sends

728
00:36:31.559 --> 00:36:34.559
<v Speaker 2>the message content and the token to Google's GCM server.

729
00:36:34.920 --> 00:36:37.960
<v Speaker 2>GCM then handles delivering that message down to the correct.

730
00:36:37.679 --> 00:36:39.079
<v Speaker 1>Device and the app received it.

731
00:36:39.280 --> 00:36:42.360
<v Speaker 2>Yes, the app needed to implement specific services, an instance

732
00:36:42.400 --> 00:36:45.360
<v Speaker 2>I listener service to handle token generation and refresh, and

733
00:36:45.440 --> 00:36:48.360
<v Speaker 2>a GCM listener service with an on message received callback

734
00:36:48.480 --> 00:36:51.519
<v Speaker 2>to actually handle incoming push messages. It worked back to

735
00:36:51.559 --> 00:36:52.280
<v Speaker 2>API eight.

736
00:36:52.239 --> 00:36:54.639
<v Speaker 1>Okay and letting users sign in easily.

737
00:36:54.840 --> 00:36:57.679
<v Speaker 2>Google sign in was becoming common. It allowed users to

738
00:36:57.719 --> 00:37:00.320
<v Speaker 2>sign into your app using their existing Google accase out,

739
00:37:00.519 --> 00:37:03.039
<v Speaker 2>avoiding the need for them to create yet another username

740
00:37:03.079 --> 00:37:05.840
<v Speaker 2>and password. It involved using the Google app a client,

741
00:37:06.159 --> 00:37:09.000
<v Speaker 2>a central entry point for Google APIs back then, and

742
00:37:09.079 --> 00:37:12.280
<v Speaker 2>adding a standard sigin button to your layout. Once signed in,

743
00:37:12.320 --> 00:37:16.360
<v Speaker 2>you could access basic profile info like their name, email, photo, url, etc.

744
00:37:17.039 --> 00:37:17.920
<v Speaker 2>With their permission, of.

745
00:37:17.840 --> 00:37:22.559
<v Speaker 1>Course, streamlining log in okay. Finally, the cookbook looked at

746
00:37:22.599 --> 00:37:25.679
<v Speaker 1>back end as a service BASH options. What was the

747
00:37:25.719 --> 00:37:26.280
<v Speaker 1>idea there?

748
00:37:26.519 --> 00:37:29.400
<v Speaker 2>The idea was simple, Building and maintaining your own server

749
00:37:29.480 --> 00:37:32.000
<v Speaker 2>back end for an app is hard work. You need

750
00:37:32.000 --> 00:37:36.840
<v Speaker 2>server infrastructure, databases, user management, APIs. It's a lot. BASS

751
00:37:36.840 --> 00:37:40.360
<v Speaker 2>providers offered a shortcut. They provided ready made back end infrastructure,

752
00:37:40.360 --> 00:37:45.880
<v Speaker 2>cloud databases, user authentication, push notification services, file storage, serverless functions,

753
00:37:46.199 --> 00:37:49.480
<v Speaker 2>all accessible via NS. That was the pitch. Focus on

754
00:37:49.519 --> 00:37:52.039
<v Speaker 2>the front end experience, let the BASS handle the back

755
00:37:52.159 --> 00:37:56.199
<v Speaker 2>end heavy lifting. The cookbook compared several providers available in

756
00:37:56.199 --> 00:37:59.960
<v Speaker 2>twenty sixteen based on things like their free tiers, monthly users,

757
00:38:00.119 --> 00:38:03.760
<v Speaker 2>API calls, features like push support and storage limits.

758
00:38:03.800 --> 00:38:05.360
<v Speaker 1>Who are some of the players back then?

759
00:38:05.599 --> 00:38:08.880
<v Speaker 2>The book detailed setup for a few app forty two

760
00:38:09.039 --> 00:38:12.840
<v Speaker 2>which seemed focused on games, back endless offering, MBS hosting,

761
00:38:12.920 --> 00:38:17.119
<v Speaker 2>APIs Buddy focusing on device sensors, Kinvey one of the

762
00:38:17.119 --> 00:38:19.679
<v Speaker 2>earlier big players, and notably.

763
00:38:19.519 --> 00:38:23.880
<v Speaker 1>Firebase AH Firebase, which Google had recently acquired around that time.

764
00:38:24.000 --> 00:38:27.760
<v Speaker 2>Exactly Firebase was highlighted particularly for its real time auto syncing,

765
00:38:27.840 --> 00:38:31.760
<v Speaker 2>database authentication, and hosting. Its acquisition by Google signaled a

766
00:38:31.760 --> 00:38:34.719
<v Speaker 2>big push into this bast space. Each provider had slightly

767
00:38:34.719 --> 00:38:37.599
<v Speaker 2>different strength set of processes. Some used MAVE and GRADEL,

768
00:38:37.639 --> 00:38:41.239
<v Speaker 2>others needed manual library inclusion and pricing models. It really

769
00:38:41.280 --> 00:38:44.159
<v Speaker 2>represented an emerging alternative to DIY back ends.

770
00:38:44.360 --> 00:38:48.480
<v Speaker 1>Wow, we've really journeyed back to twenty sixteen ANDREID development.

771
00:38:48.840 --> 00:38:51.719
<v Speaker 1>We've taken this deep dive into the Android Application Development

772
00:38:51.760 --> 00:38:55.800
<v Speaker 1>Cookbooks second Edition, giving you hopefully a really comprehensive tour.

773
00:38:56.320 --> 00:39:00.119
<v Speaker 1>We explored everything from those fundamental activities and intents, the

774
00:39:00.199 --> 00:39:03.480
<v Speaker 1>nuts and bolts of UI design with layouts, styles, themes,

775
00:39:03.519 --> 00:39:06.480
<v Speaker 1>the complexities of data management and life cycle, all those

776
00:39:06.559 --> 00:39:10.360
<v Speaker 1>user interaction points like menus and notifications, right through to

777
00:39:10.599 --> 00:39:13.840
<v Speaker 1>app readiness concerns like run time permissions, background tasks with

778
00:39:13.960 --> 00:39:16.800
<v Speaker 1>ACYNC task and that emerging world of back end as

779
00:39:16.800 --> 00:39:19.480
<v Speaker 1>a service. We really hope this deep dive has given

780
00:39:19.519 --> 00:39:21.880
<v Speaker 1>you more than just a history lesson, maybe a shortcut

781
00:39:21.880 --> 00:39:24.199
<v Speaker 1>to being well informed about a really pivotal time and

782
00:39:24.199 --> 00:39:27.360
<v Speaker 1>Android's evolution, and maybe spark some aha moments about the

783
00:39:27.360 --> 00:39:29.719
<v Speaker 1>core principles that while still drive a lot of mobile

784
00:39:29.719 --> 00:39:32.960
<v Speaker 1>development today, even if the tools look different. It's honestly

785
00:39:33.000 --> 00:39:35.760
<v Speaker 1>fascinating to see how many of those fundamental recipes from

786
00:39:35.800 --> 00:39:39.519
<v Speaker 1>twenty sixteen laid the groundwork, even with all the changes since. So,

787
00:39:39.639 --> 00:39:42.599
<v Speaker 1>as you think about everything we discussed today from twenty sixteen,

788
00:39:43.039 --> 00:39:45.400
<v Speaker 1>you know, wrestling with the activity life cycle manually, the

789
00:39:45.400 --> 00:39:48.639
<v Speaker 1>pitfalls of async task, the early days of malaysious, what

790
00:39:48.800 --> 00:39:52.239
<v Speaker 1>foundational concepts do you think still ring true, maybe as

791
00:39:52.280 --> 00:39:56.599
<v Speaker 1>core design principles, and which parts feel completely alien now

792
00:39:56.639 --> 00:40:00.480
<v Speaker 1>totally revolutionized or abstracted away in modern Android development? And

793
00:40:00.559 --> 00:40:03.719
<v Speaker 1>maybe think about this, what recipes would be absolutely essential

794
00:40:03.760 --> 00:40:05.880
<v Speaker 1>in an Android application development cook book if it were

795
00:40:05.880 --> 00:40:08.719
<v Speaker 1>published to day. What would be the chapter headings reflecting

796
00:40:08.760 --> 00:40:11.440
<v Speaker 1>the biggest shifts and the most critical techniques developers need

797
00:40:11.480 --> 00:40:14.239
<v Speaker 1>to master now compared to back in twenty sixteen,
