Difference between revisions of "Book Review: Learning Android by Marko Gargenta (O'Reilly Book)"

From Ittichai Chammavanijakul's Wiki
Jump to navigation Jump to search
Line 57: Line 57:
 
** They are interfaces for sharing data between applications.
 
** They are interfaces for sharing data between applications.
 
** The Content Provider API adheres to the CRUD principle http://en.wikipedia.org/wiki/Create,_read,_update_and_delete.
 
** The Content Provider API adheres to the CRUD principle http://en.wikipedia.org/wiki/Create,_read,_update_and_delete.
**
+
** For example, the Contacts Provider is a content provider that exposes all user contact data to other applications.

Revision as of 14:13, 18 April 2011

Learning Android (http://ofps.oreilly.com/titles/9781449390501/index.html) by Marko Gargenta O'Reilly Books

Chapter 1: Android Overview

Chapter 2: The Stack

  • Android stacks
    • Linux kernel (display, camera, keypad, etc.)
    • Native libraries (Android runtime (CoreLibs, Delvik VM), OpenGL, SSL, SQLite, Webkit, etc.)
    • Application framework (Activity Manager, Content providers, Notification manager, etc.
    • Applications (Home, Contacts, Phone, Browser, etc.)
  • GNU libc, the default C library for Linux which Android is using, is licensed under GPL license, which requires any changes we release to be pushed back to the open source community. On the other hand, Android and some third-party open source libraries are licensed under an Apache/MIT license, which does not require derivative works to be open-sourced.
  • Dalvik is a purpose-built virtual machine designed specifically for Android, developed by Dan Bornstein and his team at Google.
  • While Java language, Java tools and Java libraries are free, the Java VM is not. Dalvik VM in Android is to replace the Java VM.
  • Differences between Android and Java
    • Java source code => (Java compiler) => Java byte code (running on Java VM).
    • Java source code => (Java compiler) => Java byte code => (Dex compiler) => Dalvik byte code => Dalvik executable (running on Dalvik VM).
  • Android Java is a nonstandard collection of Java classses. Its set of libraries is closet to Java Standard Edition.
  • The APK is a single application package file. It has three main components:
    • Dalvik executable = compiled code to executable
    • Resources = non-code - images, audio, etc.
    • Native libraries (optional) = some native code if any.

Chapter 3: Quick Start

  • Android SDK download page - http://developer.android.com/sdk
  • Installing the SDK http://developer.android.com/sdk/installing.html
  • Installing Eclipse http://eclipse.org/ - Eclipse IDE for Java Developers (not the twice-as-large Eclipse for Java EE Developers) is recommended.
  • Project files:
    • Manifest file has all application's main building blocks, what permission is required to run.
    • Layout XML code files specify the layout of the screen.
    • Strings (another XML file) contains all texts that application uses.
    • The R file is the glue between the Java and resources. It's automatically generated file.
    • Java source code contains all codes which will be converted to a Dalvik executable.
  • Emulator
    • Android SDK ships with a true emulator based on QEMU.

Chapter 4: Main Building Blocks

  • An Activity is usually a single screen on the device.
  • Activity Life Cycle
    • Launching an activity is expensive.
    • Transition from the Starting state to Running state is the most expensive.
    • The Running State is when one running activity is in focus.
    • The Paused state is when an activity is not in focus - showing dialog boxes
    • The Stopped state is when an activity is not visible, but still in memory (just in case if user might get back to it, restarting the Stopped activity is far cheaper then starting from scratch.
    • The Destroyed state is when the destroyed activity is no longer in memory.
  • Intents
    • The Intents are messages that are communicated among building blocks.
  • Services
    • Services run in the background, and can perform the same actions as the activities, but they don't have any user interfaces.
  • Content Providers