Android For Java Developers
Upcoming SlideShare
Loading in...5
×
 

Android For Java Developers

on

  • 1,104 views

This presentation was given at

This presentation was given at

Statistics

Views

Total Views
1,104
Views on SlideShare
1,103
Embed Views
1

Actions

Likes
0
Downloads
40
Comments
0

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Open: - Android does not differentiate between the phone's core applications and third-party applications ; Developers have full access to the same framework APIs used by the core applications. The application architecture is designed to simplify the reuse of components; any application can publish its capabilities and any other application may then make use of those capabilities (subject to security constraints enforced by the framework). This same mechanism allows components to be replaced by the user. -Independent developers are also allowed to create applications that replace core phone functionality (like dialer, browser, contacts list, home screen, etc). Low Barrier to entry Easy to develop -Programming model is based on Java. Applications are written in Java, and just call new APIs. Tools used are based on existing most used tools (Eclipse). Also allows development without using Eclipse (if you would prefer command line – can use adb, etc). -Can run development tools on Windows, Linux, and OSX. Open Market -Very minimal oversight over what can be sold (mostly regarding security, or explicit material). You can publish replacements for any of the core applications (including the keyboard, or browser). -All applications are equal Feature Rich Platform -Multitasking -Access to native phone events (SMS, Phone ringing, etc) -3 rd Party APIs -UI Customization -Interpreted language support allowed (Python, JS, Ruby, etc) -Flash
  • http://developer.android.com/guide/basics/what-is-android.html Linux Kernel Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. The kernel also acts as an abstraction layer between the hardware and the rest of the software stack. Runtime + Dalvik virtual machine VM optimized for mobile devices; Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included "dx" tool. The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and low-level memory management. By default, every application runs in its own Linux process. Android starts the process when any of the application's code needs to be executed, and shuts down the process when it's no longer needed and system resources are required by other applications. Each process has its own Java virtual machine (VM), so application code runs in isolation from the code of all other applications. By default, each application is assigned a unique Linux user ID. Permissions are set so that the application's files are visible only that user, only to the application itself — although there are ways to export them to other applications as well. Native Libraries Open GL – custom 2D lib; 3D graphics are based on OpenGL ES 1.0 specification SQLite for structured data storage Integrated browser based on the open source WebKit engine Media support for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF) Camera, GPS, compass, and accelerometer (hardware dependent) Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plugin for the Eclipse IDE Application Framework: Activity Manager – Resource Manager – Location Manager – Notification Manager – Content Provider - Applications
  • http://developer.android.com/guide/basics/what-is-android.html Linux Kernel Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. The kernel also acts as an abstraction layer between the hardware and the rest of the software stack.
  • http://developer.android.com/guide/basics/what-is-android.html Runtime + Dalvik virtual machine VM optimized for mobile devices; Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) - generated by included “dx tool”. .dex format which is optimized for minimal memory footprint. The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and low-level memory management. By default, every application runs in its own Linux process. Android starts the process when any of the application's code needs to be executed, and shuts down the process when it's no longer needed and system resources are required by other applications. Each process has its own Java virtual machine (VM), so application code runs in isolation from the code of all other applications. By default, each application is assigned a unique Linux user ID. Permissions are set so that the application's files are visible only that user, only to the application itself — although there are ways to export them to other applications as well.
  • Native Libraries Open GL – custom 2D lib; 3D graphics are based on OpenGL ES 1.0 specification SQLite for structured data storage Integrated browser based on the open source WebKit engine Media support for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF) Camera, GPS, compass, and accelerometer (hardware dependent) Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plugin for the Eclipse IDE
  • Application Framework: A rich and extensible set of Views that can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser Content Providers that enable applications to access data from other applications (such as Contacts), or to share their own data A Resource Manager , providing access to non-code resources such as localized strings, graphics, and layout files A Notification Manager that enables all applications to display custom alerts in the status bar An Activity Manager that manages the lifecycle of applications and provides a common navigation backstack
  • Applications
  • http://developer.android.com/guide/basics/what-is-android.html Linux Kernel Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. The kernel also acts as an abstraction layer between the hardware and the rest of the software stack. Runtime + Dalvik virtual machine VM optimized for mobile devices; Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included "dx" tool. The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and low-level memory management. By default, every application runs in its own Linux process. Android starts the process when any of the application's code needs to be executed, and shuts down the process when it's no longer needed and system resources are required by other applications. Each process has its own Java virtual machine (VM), so application code runs in isolation from the code of all other applications. By default, each application is assigned a unique Linux user ID. Permissions are set so that the application's files are visible only that user, only to the application itself — although there are ways to export them to other applications as well. Native Libraries Open GL – custom 2D lib; 3D graphics are based on OpenGL ES 1.0 specification SQLite for structured data storage Integrated browser based on the open source WebKit engine Media support for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF) Camera, GPS, compass, and accelerometer (hardware dependent) Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plugin for the Eclipse IDE Application Framework: Activity Manager – Resource Manager – Location Manager – Notification Manager – Content Provider - Applications
  • Other Tools: android To create/update Android projects and to create/move/delete AVDs. Android Emulator To run your Android applications on an emulated Android platform. Android Debug Bridge To interface with your emulator or connected device (install apps, shell the device, issue commands, etc.).
  • Android (android.bat) – command line tool to allow developer to manage SDK and AVDs Emulator (Mobile device emulator) -- a virtual mobile device that runs on your computer. The emulator lets you prototype, develop, and test Android applications without using a physical device. Each AVD is made up of: A hardware profile.  You can set options to define the hardware features of the virtual device. For example, you can define whether the device has a camera, whether it uses a physical QWERTY keyboard or a dialing pad, how much memory it has, and so on. A mapping to a system image.  You can define what version of the Android platform will run on the virtual device. You can choose a version of the standard Android platform or the system image packaged with an SDK add-on. Other options.  You can specify the emulator skin you want to use with the AVD, which lets you control the screen dimensions, appearance , and so on. You can also specify the emulated SD card to use with the AVD. A dedicated storage area on your development machine, in which is stored the device's user data (installed applications, settings, and so on) and emulated SD card. ADB: Android Debug Bridge (adb) is a versatile tool lets you manage the state of an emulator instance or Android-powered device. It is a client-server program that includes three components: A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients. A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device. A daemon, which runs as a background process on each emulator or device instance. DDMS: Includes: file explorer; Memory/Thread inspector (dumpsys, dumpstate); tools to execute Garbage Collection; Screen capture;
  • http://developer.android.com/resources/tutorials/hello-world.html Steps to create a new project. Once you complete the New Project Wizard, ADT creates the following folders and files in your new project: src/ Includes your stub Activity Java file. All other Java files for your application go here. / (e.g., Android 1.1/) Includes the android.jar file that your application will build against. This is determined by the build target that you have chosen in the New Project Wizard . gen/ This contains the Java files generated by ADT, such as your R.java file and interfaces created from AIDL files. assets/ This is empty. You can use it to store raw asset files. See Resources and Assets . res/ A folder for your application resources, such as drawable files, layout files, string values, etc. See Resources and Assets . AndroidManifest.xml The Android Manifest for your project. See The AndroidManifest.xml File . default.properties This file contains project settings, such as the build target. This files is integral to the project, as such, it should be maintained in a Source Revision Control system. It should never be edited manually — to edit project properties, right-click the project folder and select "Properties".
  • Activity – (Noun) A single screen, your application is made up of one or more of these Intent – (Verb) code to perform an action – used to call an activity, service or broadcast receiver; this is the wiring between activities; Intent messaging is a facility for late run-time binding between components in the same or different applications Resource – text, pictures, sound, etc; These things are all abstracted from the code, and compiled into a class called R.class Manifest File – always named AndroidManifest.xml – bundled into .apk file (that contains the applications code, files, and resources), declares the components of an application, describes security permissions required by the app, and lists required library dependancies. Widget – miniature application views that can be embedded in other applications (such as the home screen), and receive periodic updates Service – a task that can be running, but is not visible (background apps FTW!) Broadcast Receiver – a component that does nothing but receive and react to broadcast announcements. These don’t contain a UI, but could be used to start an activity when an event triggers it. Ex. Listed for timezone, or low battery warnings. Security and Permissions - A central design point of the Android security architecture is that no application, by default, has permission to perform any operations that would adversely impact other applications, the operating system, or the user. Android is a multi-process system, in which each application (and parts of the system) runs in its own process. Most security between applications and the system is enforced at the process level through standard Linux facilities, such as user and group IDs that are assigned to applications. Additional finer-grained security features are provided through a "permission" mechanism that enforces restrictions on the specific operations that a particular process can perform, and per-URI permissions for granting ad-hoc access to specific pieces of data. A basic Android application has no permissions associated with it, meaning it can not do anything that would adversely impact the user experience or any data on the device. To make use of protected features of the device, you must include in your AndroidManifest.xml one or more tags declaring the permissions that your application needs. Content Provider – Functionality designed to allow data to be shared across applications. It is data and an API that any app can access; Android uses this feature to provide contact info; they can be accessed through the android.provider package (some require permissions to access)
  • LinearLayout – arranges children in a single row/column. FrameLayout – arranges children so they show up at the top left. Commonly used for Activities with a single element, or tabbed views RelativeLayout – elements are arranges in relation to each other. (Element X is above Y). TableLayout – elements arranged in cells (like HTML tables)
  • Activity – (Noun) A single screen, your application is made up of one or more of these
  • Intent – (Verb) code to perform an action – used to call an activity, service or broadcast receiver; this is the wiring between activities; Intent messaging is a facility for late run-time binding between components in the same or different applications
  • Manifest File – always named AndroidManifest.xml – bundled into .apk file (that contains the applications code, files, and resources), declares the components of an application, describes security permissions required by the app, and lists required library dependancies.
  • Manifest File – always named AndroidManifest.xml – bundled into .apk file (that contains the applications code, files, and resources), declares the components of an application, describes security permissions required by the app, and lists required library dependancies.
  • Manifest File – always named AndroidManifest.xml – bundled into .apk file (that contains the applications code, files, and resources), declares the components of an application, describes security permissions required by the app, and lists required library dependancies.
  • Resource – text, pictures, sound, etc; These things are all abstracted from the code, and compiled into a class called R.class
  • Resource – text, pictures, sound, etc; These things are all abstracted from the code, and compiled into a class called R.class
  • Widget – miniature application views that can be embedded in other applications (such as the home screen), and receive periodic updates Service – a task that can be running, but is not visible (background apps FTW!) Broadcast Receiver – a component that does nothing but receive and react to broadcast announcements. These don’t contain a UI, but could be used to start an activity when an event triggers it. Ex. Listed for timezone, or low battery warnings. Security and Permissions - A central design point of the Android security architecture is that no application, by default, has permission to perform any operations that would adversely impact other applications, the operating system, or the user. Android is a multi-process system, in which each application (and parts of the system) runs in its own process. Most security between applications and the system is enforced at the process level through standard Linux facilities, such as user and group IDs that are assigned to applications. Additional finer-grained security features are provided through a "permission" mechanism that enforces restrictions on the specific operations that a particular process can perform, and per-URI permissions for granting ad-hoc access to specific pieces of data. A basic Android application has no permissions associated with it, meaning it can not do anything that would adversely impact the user experience or any data on the device. To make use of protected features of the device, you must include in your AndroidManifest.xml one or more tags declaring the permissions that your application needs. Content Provider – Functionality designed to allow data to be shared across applications. It is data and an API that any app can access; Android uses this feature to provide contact info; they can be accessed through the android.provider package (some require permissions to access)
  • Widget – miniature application views that can be embedded in other applications (such as the home screen), and receive periodic updates Service – a task that can be running, but is not visible (background apps FTW!) Broadcast Receiver – a component that does nothing but receive and react to broadcast announcements. These don’t contain a UI, but could be used to start an activity when an event triggers it. Ex. Listed for timezone, or low battery warnings. Security and Permissions - A central design point of the Android security architecture is that no application, by default, has permission to perform any operations that would adversely impact other applications, the operating system, or the user. Android is a multi-process system, in which each application (and parts of the system) runs in its own process. Most security between applications and the system is enforced at the process level through standard Linux facilities, such as user and group IDs that are assigned to applications. Additional finer-grained security features are provided through a "permission" mechanism that enforces restrictions on the specific operations that a particular process can perform, and per-URI permissions for granting ad-hoc access to specific pieces of data. A basic Android application has no permissions associated with it, meaning it can not do anything that would adversely impact the user experience or any data on the device. To make use of protected features of the device, you must include in your AndroidManifest.xml one or more tags declaring the permissions that your application needs. Content Provider – Functionality designed to allow data to be shared across applications. It is data and an API that any app can access; Android uses this feature to provide contact info; they can be accessed through the android.provider package (some require permissions to access)

Android For Java Developers Android For Java Developers Presentation Transcript

  • Android for Java Developers Denver Java Users Group Jan 11, 2012 -Mike Wolfson @mikewolfson
  • Why Android?
    • Open APIs – everyone’s equal
    • Low Barrier to entry
      • Run app on your own device - $0
      • Sell through Google Market - $25
    • Easy to develop apps
      • Especially for Java Developers
      • Platform agnostic
    • Open Market (or download from anywhere)
    • Feature Rich platform
  • Framework Overview
    • http://developer.android.com/guide/basics/what-is-android.html
  • Framework – Linux Kernel
    • Core system services
    • Handles security, memory management, process management, network access, etc
    • Abstraction layer between OS and hardware
  • Framework - Dalvik
    • Virtual Machine
    • Optimized for mobile devices
    • Every app runs in its own instance of VM
    • Runs classes compiled by Java, and transformed into .dex files
  • Framework - Libraries
    • Variety of libraries to provide built in functionality.
  • Framework – Application Framework
    • Provides functionality to allow Applications to interact with underlying OS and other applications
    • Designed to simplify the reuse of components, and allow applications to publish, or make use of the capabilities of other applications
  • Framework – Applications
    • The layer where custom-built applications live.
    • This is the place where most mobile developers will interact with Android. Your App Here!
  • Framework Overview
  • Get Developer Tools
    • SDK
      • http://developer.android.com/sdk/index.html
      • Requires Java SDK (5.0 +)
      • Updating versions
      • What the different versions mean
    • ADT Plugin (for Eclipse)
      • http://developer.android.com/guide/developing/tools/adt.html
      • Need Eclipse Ganymede (3.4+)
      • Update site: https://dl-ssl.google.com/android/eclipse
    • Can develop without Eclipse
  • Developer Tools (cont )
    • Android command
    • Emulator
      • Android Virtual Devices (AVD)
    • Android Debug Bridge (ADB)
      • Command line tool for interacting with phone/emulator.
    • Dalvik Debug Monitor Server (DDMS)
      • Debugging tool providing: screen capture, memory info, logging, info spoofing)
    • http://developer.android.com/guide/developing/tools/index.html
  • Developing an App
    • Create a new project
      • Project content overview
    • Code
    • Test on emulator (or device)
    • Debug
    • Sign
    • Export to device
      • As APK ( A ndroid P ac K age file)
  • Terminology
      • Most Commonly used elements
        • Activity
        • Intent
        • Manifest file
        • Resources and Assets
        • Layout
        • Fragment
  • Terminology - Layout
    • Layout – describes the UI of an activity
      • Enables separation of UI from logic
      • There are a variety of layouts you can use including: Linear, Table, Relative, and Frame
  • Terminology - Activity
    • Activity – (Noun) A single screen, your application is made up of one or more of these.
      • Always extends Activity
  • Terminology - Intent
    • Intent – (Verb) code to perform an action
      • Wiring between activities, services, broadcast receivers, or other functions
      • facility for late run-time binding between components in the same or different applications
      • Rich set of Intent in Android provide excellent way of executing specific actions
  • Fragments
    • Fragments represent a behavior or portion of a UI.
    • Designed to collect a unit of UI and behavior into a reusable component
    • Don’t have own lifecycle – and must be embedded in an Activity
  • Fragments
  • Terminology - Manifest
    • Manifest File – describes your app
      • always named AndroidManifest.xml
      • declares the components of an application, describes security permissions required by the app, and lists required library dependencies
  • Terminology - Resources
    • Resource – text, pictures, sound, etc
      • are all abstracted from the code and logic
      • compiled and managed by system generated R.class file
      • Instantiate by getting reference to object
  • Resources
    • Multiple Layouts and
    • Graphic Assets
    • Can also be Used for
    • language localization
    • Tip: use Density
    • Independent Pixels (DP)
    • Draw9Patch
  • Terminology - APK
    • Android Application File
    • User can install apps from many sources
    • Developer can upload updates easily
  • Terminology – cont.
      • Other important elements
        • Widget
        • Service
        • Broadcast Receiver
        • Security and Permission
        • Content Provider
  • Learn More
    • http://developer.android.com
    • Denver Droids
      • http://www.denverdroids.com/
    • http://forum.xda-developers.com
    • http://www.stackoverflow.com
    • http://developer.android.com
    • Google Groups (Forums)
  • Questions?
    • @mikewolfson
    • Google +: Mike Wolfson
    • [email_address]
    • Slideshare: http://www.slideshare.net/mswolfson
    • Dropbox: http://dl.dropbox.com/u/23589031/DJUG.zip
    • Beer?!