Advertisement
Guest User

Kappa

a guest
Oct 1st, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.86 KB | None | 0 0
  1. [MUSIC]
  2. Today I'm going to introduce
  3. you to the Android Platform.
  4. I'll start by giving you an overview
  5. of the Android Platform, and
  6. the components that make it up.
  7. And then I'll present each
  8. of these components and
  9. discuss how they help developers
  10. build great mobile applications.
  11. So let's get started.
  12. The Android platform is a software stack,
  13. and it was designed primarily, but
  14. not exclusively, to support mobile
  15. devices such as phones and tablets.
  16. And this stack has several layers,
  17. going all the way from low-level operating
  18. system services that manage the device
  19. itself, up to sample applications,
  20. things like the phone dialer, the contacts
  21. database, and the web browser.
  22. Android also comes with
  23. a software developers kit, or
  24. SDK, which is used to create
  25. Android applications.
  26. And finally, there's tons of
  27. documentation, tutorials, blogs, and
  28. examples that you can use to improve
  29. your own understanding of Android, and
  30. I encourage you to take advantage
  31. of all these resources.
  32. Now this graphic represents
  33. the Android software stack.
  34. And as you can see,
  35. it's organized into several layers.
  36. At the bottom there's
  37. the Linux kernel layer.
  38. Above that, there are system libraries and
  39. the Android run time system.
  40. Above that, there's a rich
  41. application framework player to
  42. support the development
  43. of new applications,.
  44. And at the very top, Android provides
  45. some standard applications, again,
  46. things like the phone dialer, the web
  47. browser, and the contacts database.
  48. So let's look at each of
  49. these layers in detail,
  50. starting with the Linux kernel layer.
  51. The Linux kernel layer is the lowest layer
  52. of software in the Android platform.
  53. This layer provides the core services that
  54. any Android computing device will rely on.
  55. Android's Linux kernel,
  56. just like any Linux kernel, provides
  57. generic operating system services.
  58. For example,
  59. it provides a permissions architecture so
  60. that you can restrict access to data and
  61. resources to only those processes
  62. that have the proper authorizations.
  63. It supports memory and process management,
  64. so that multiple processes can
  65. run simultaneously without
  66. interfering with each other.
  67. It handles low-level details of file and
  68. network I/O.
  69. And it also allows device drivers to
  70. be plugged in so that Android can
  71. communicate with a wide range of
  72. low-level hardware components that
  73. are often coupled to computing devices,
  74. things like memory and radios and cameras.
  75. In addition to the common services
  76. supported by any Linux kernel,
  77. Android's Linux kernel also includes
  78. several Android-specific components.
  79. For example,
  80. Android's Linux kernel includes its own
  81. power management services because mobile
  82. devices often run on battery power.
  83. It provides its own memory sharing and
  84. memory management features, because
  85. mobile devices often have limited memory.
  86. And Android's Linux kernel also includes
  87. its own inter-process communication
  88. mechanism called the binder, which allows
  89. multiple processes to share data and
  90. services in sophisticated ways.
  91. And of course, this is just a few
  92. of the Android-specific features.
  93. There are many others as well.
  94. Next layer up includes
  95. a variety of system libraries.
  96. These libraries are typically
  97. written in C and
  98. C++, and for that reason they are often
  99. referred to as the native libraries.
  100. And these native libraries
  101. handle a lot of the core,
  102. performance-sensitive activities
  103. on your device,
  104. things like quickly rendering web
  105. pages and updating the display.
  106. And for example, Android has its own
  107. System C Library, which implements
  108. the standard OS system calls, which do
  109. things like process and thread creation,
  110. mathematical computations,
  111. memory allocation, and much more.
  112. There's the Surface Manager,
  113. for updating the display.
  114. A media framework, for
  115. playing back audio and video files.
  116. Webkit, for rendering and
  117. displaying web pages.
  118. OpenGL for high performance graphics.
  119. And SQLite for
  120. managing in-memory relational databases.
  121. In addition to the system libraries, this
  122. layer also includes the Android Runtime,
  123. which supports writing and
  124. running Android applications.
  125. And there are two components in
  126. the Android Runtime that we'll talk
  127. about today, the core Java libraries and
  128. the Dalvik Virtual Machine.
  129. Let's talk about each
  130. of those one at a time.
  131. Now first, Android applications
  132. are typically written in
  133. the Java programming language.
  134. And to make it easier
  135. to write applications,
  136. Android provides a number of
  137. reusable Java building blocks.
  138. For instance, the Java and Java X, or Java
  139. extensions packages include basic software
  140. for things like common data structures,
  141. concurrency mechanisms and file I/O.
  142. The Android packages have software
  143. that's specific to the life cycle of
  144. mobile applications.
  145. The ORG packages support various
  146. internet or web operations.
  147. And the JUnit packages support
  148. the unit testing of applications.
  149. The second part of the Android Runtime
  150. is the Dalvik Virtual Machine.
  151. The Dalvik virtual machine is
  152. the software that actually executes
  153. Android applications.
  154. Now as I just told you, Android
  155. applications are typically written in
  156. Java, so you might have assumed that
  157. since they're written in Java they would
  158. probably run on a standard Java virtual
  159. machine, but in fact that's not the case.
  160. What typically happens is that
  161. developers first write their
  162. applications in the Java
  163. programming language.
  164. Then a Java compiler will
  165. compile the Java source code
  166. files into multiple Java bytecode files.
  167. Next, a tool called DX transforms the Java
  168. bytecodes into a single file of a
  169. different bytecode format called DEX, and
  170. this bytecode file is
  171. usually called classes.dex.
  172. Next the DEX file is packaged with
  173. other application resources and
  174. installed on the device.
  175. And finally when the user
  176. launches the application,
  177. the Dalvik Virtual Machine will
  178. then execute the classes.dex file.
  179. Now the reason for doing all this
  180. is that the Dalvik Virtual Machine,
  181. unlike the the Java Virtual Machine,
  182. was specifically designed to run in
  183. the resource-constrained environment
  184. which is typical of mobile devices.
  185. Now when I say resource-constrained,
  186. what I mean is that compared
  187. to a typical desktop device,
  188. the typical mobile device is less
  189. powerful and more limited in many ways.
  190. For example, it will probably have
  191. a slower CPU, less memory and
  192. a limited battery life.
  193. So if you're interested in finding out
  194. more about the Dalvik Virtual Machine
  195. itself then I recommend you take
  196. a look at this video, Dalvik Virt,
  197. VM Internals by Dan Bornstein of Google.
  198. The next layer in the Android software
  199. stack is the application framework.
  200. The application framework
  201. contains reusable software that
  202. many mobile applications
  203. are likely to need.
  204. For example, as we'll see in a minute,
  205. the View system contains common graphical
  206. elements, things like buttons, and
  207. icons, that many applications
  208. include in their user interfaces.
  209. Let's take a deeper look at
  210. some of these components.
  211. One application framework
  212. component is the Package Manager.
  213. The Package Manager is
  214. essentially a database that
  215. keeps track of all the applications
  216. currently installed on your device.
  217. So here's the home screen of my phone.
  218. When I click on the Launcher icon,
  219. the phone shows me a bunch of icons,
  220. each one representing an application
  221. package that's stored on my phone.
  222. The Package Manager stores information
  223. about these applications, and
  224. that's useful for several reasons.
  225. For example, it allows applications
  226. to find and contact each other so
  227. that one application can share data
  228. with another application, or so
  229. that one application can
  230. request services from another.
  231. Another application framework
  232. component is the Window Manager.
  233. The Window Manager,
  234. as the name suggests, manages the many
  235. windows that comprise applications.
  236. Here I'm launching the Browser
  237. application, which appears as two windows.
  238. At the top,
  239. there's the System Notification bar,
  240. which displays various status indicators
  241. that tell the user about things
  242. like WiFi signal strength, remaining
  243. battery power, and the current time.
  244. There's also a Main Application window,
  245. that in this case is showing
  246. the current web page.
  247. An application can also
  248. use various sub windows,
  249. such as when it shows menus or dialogs.
  250. As I mentioned earlier, the application
  251. framework also contains the View System.
  252. The View System contains many common
  253. graphical user interface elements,
  254. such as icons, text entry boxes,
  255. buttons, and much more.
  256. Let's take a look at
  257. the phone application.
  258. As you can see,
  259. the phone application's top level user
  260. interface is organized as a set of tabs.
  261. And each tab corresponds
  262. to a different user
  263. interface that supports
  264. a different set of tasks.
  265. The Phone tab shows me a phone dialer.
  266. The Call Log tab shows a list of
  267. recent incoming and outgoing calls.
  268. And the Contacts tab shows
  269. a list of stored contacts.
  270. Now as I just said,
  271. when I select the Phone tab, I'm shown a
  272. user interface that mimics a phone keypad.
  273. That keypad is made up of view system
  274. components, things like buttons and
  275. text views.
  276. And then the application will listen as I
  277. press these buttons and then respond by
  278. writing the corresponding digits to a text
  279. view to show me what number I'm dialing.
  280. The next application framework
  281. component is the Resource Manager.
  282. This component manages the non-compiled
  283. resources that make up an application,
  284. things like strings, graphics,
  285. and user interface layout files.
  286. And to give you example of
  287. non-compiled resources,
  288. let's go back to the phone
  289. application again.
  290. Now this tab has some English words on it,
  291. and that's fine because I speak English.
  292. But Android is available around the world,
  293. it's not limited to English speakers, and
  294. so it's important that we have an easy
  295. way to customize applications for
  296. other languages.
  297. And one way that Android
  298. supports that is that,
  299. that it lets you define
  300. strings in multiple languages.
  301. For example, the phone
  302. application has a string file for
  303. Italian words as well as one for
  304. English words.
  305. So if you speak Italian, then you can
  306. go into the Settings application and
  307. select Italian as your default language.
  308. Now, if I go back and rerun the phone
  309. application, you'll see that Android will
  310. use the appropriate Italian words
  311. rather than the English words.
  312. And, of course, you can do this for
  313. as many languages as makes sense for
  314. your application.
  315. Another application framework
  316. component is the Activity Manager.
  317. Now at a high level,
  318. Android activities often correspond
  319. to a single user interface screen.
  320. Applications are then
  321. created by stringing together
  322. multiple activities through
  323. which the user can navigate.
  324. The Activity Manager helps to coordinate
  325. and support that kind of navigation.
  326. So suppose I want to listen to some music.
  327. So here I'll click on the Launcher
  328. icon to show my applications.
  329. From there,
  330. I can click on the Music Player icon.
  331. And that will start an activity that
  332. brings up a user interface screen
  333. showing the music I have on my device,
  334. in this case sorted by artist.
  335. I can select an artist, and
  336. see the albums by that artist.
  337. I can select one album by clicking on it.
  338. And this starts another activity that
  339. brings up another user interface screen,
  340. showing the songs in
  341. the album I just selected.
  342. And now if I hit the Back button,
  343. I can go back to the last activity,
  344. and for example,
  345. I can choose a different album.
  346. Now I can click on a specific song in that
  347. album, and yet another activity starts up
  348. that brings up yet another user interface
  349. screen, allowing me to play this song.
  350. Another application framework component
  351. implements Content Providers.
  352. Content Providers are essentially
  353. databases that allow applications to
  354. store and share structured information.
  355. For example, here we see that the phone
  356. application can access stored
  357. contact information and
  358. use it to dial a phone number.
  359. And it can do that because
  360. the contact information is stored in
  361. a Content Provider.
  362. And even better, Content Providers are
  363. designed to work across applications so
  364. not only can the phone dialer use
  365. the contact information, but so
  366. can the MMSM, messaging application and
  367. so can various social media applications.
  368. Let's take a look.
  369. So going back to the phone application,
  370. I can select the Contact tab to
  371. access stored contact information.
  372. I can select one of the contacts
  373. to quickly dial that contact.
  374. Now as I said, I can do that
  375. because contact information is
  376. stored in a Content Provider.
  377. And again, even better, Content Providers
  378. are designed to work across applications.
  379. So not only can the phone dialer use
  380. the contacts, but so can the MMS messaging
  381. application, and so can Twitter, Facebook,
  382. my email readers, and things like that.
  383. The next application framework
  384. component is the Location Manager.
  385. The Location Manager allows
  386. applications to receive location and
  387. movement information,
  388. such as that generated by the GPS system.
  389. And this allows applications to
  390. perform context-specific tasks,
  391. things like finding directions
  392. from the current location.
  393. Now here I'm calling up
  394. the Google Maps application,
  395. which queries the Location Manager for
  396. my current location, and
  397. then shows a map of the area
  398. around that current location.
  399. The last application framework
  400. component I'll talk about today
  401. is the Notification Manager.
  402. The Notification Manager allows
  403. applications to place information in
  404. the Notification bar, for example,
  405. to let users know that
  406. certain events have occurred.
  407. For example, suppose I want to
  408. send my wife an MMS message.
  409. And let's suppose that at right at
  410. this minute, she's writing an email or
  411. making a phone call or whatever.
  412. So although she probably wants to know
  413. that I've sent her an MMS message,
  414. she might not want that
  415. to disrupt her right now.
  416. Well, Android handles this
  417. with a Notification Manager.
  418. And the way that works is that there's
  419. some software running on her phone
  420. that's always listening for
  421. incoming MMS messages.
  422. When one arrives, that software uses
  423. the Notification Manager to place
  424. an icon in her phone's Notification bar.
  425. And that's shown as
  426. a little smiley face icon.
  427. And I've whited out some of the,
  428. some of the information there for privacy.
  429. Now when she's ready,
  430. she can pull down on the Notification bar,
  431. which then shows more information
  432. about the specific notification.
  433. And if she clicks on that notification,
  434. the MMS application will start up and
  435. she can read and
  436. hopefully respond to my message.
  437. The last layer of the Android software
  438. stack is the Application layer.
  439. As I said earlier, Android comes
  440. with some built-in applications, and
  441. these include things like the home screen,
  442. the phone dialer, the web browser,
  443. an email reader, and more.
  444. And one of the things that's really
  445. nice about Android is that none of
  446. these apps is hard-coded into the system.
  447. If you have a better app,
  448. you can substitute your app for
  449. any of these standard apps.
  450. So that's all for the Android platform.
  451. Please join me
  452. next time when we'll explore
  453. the Android Development Environment.
  454. See you then.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement