Você está na página 1de 26

Introducing

Android
- Nishanth
What is Android?
• Android is a software stack for mobile
devices that includes an operating system,
middleware and key applications.
• The Android SDK provides the tools and
APIs necessary to begin developing
applications on the Android platform using
the Java programming language.
What is Android?
Developers can create applications for the
platform using the Android SDK.
Applications are written using the Java
programming language and run on Dalvik, a
custom virtual machine designed for
embedded use, which runs on top of a
Linux kernel.
Features
• Application framework enabling reuse and replacement of components

• Dalvik virtual machine optimized for mobile devices

• Integrated browser based on the open source WebKit engine

• Optimized graphics powered by a custom 2D graphics library; 3D


graphics based on the OpenGL ES 1.0 specification (hardware acceleration
optional)

• SQLite for structured data storage

• Media support for common audio, video, and still image formats
(MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF)

• GSM Telephony (hardware dependent)

• Bluetooth, EDGE, 3G, and WiFi (hardware dependent)

• Camera, GPS, compass, and accelerometer (hardware dependent)


Android Architecture
Linux Kernel

• Android relies on Linux version 2.6.x for core system services


• The kernel acts as an abstraction layer between the hardware and
the rest of the software stack.
• Linux manages variety of services such as:
security, memory management, process management, network
stack, and driver model.
Libraries

• Android includes a set of C/C++ libraries used by various


components of the Android system.
• These capabilities are exposed to developers through the
Android application framework.
• Relies on the Linux kernel for underlying functionality
> Threading and Low-level memory management.
Libraries

• System C library - a BSD-derived implementation of the


standard C system library (libc), tuned for embedded Linux-based
devices

• Media Libraries - based on PacketVideo's OpenCORE;


the libraries support playback and recording of many popular audio
and video formats, as well as static image files, including MPEG4, H.
264, MP3, AAC, AMR, JPG, and PNG

• Surface Manager - manages access to the display


subsystem and seamlessly composites 2D and 3D graphic layers from
multiple applications

• LibWebCore - a modern web browser engine which


powers both the Android browser and an embeddable web view
Libraries

• SGL - the underlying 2D graphics engine

• 3D libraries - an implementation based on OpenGL ES 1.0 APIs;


the libraries use either hardware 3D acceleration (where available) or
the included, highly optimized 3D software rasterizer

• FreeType - bitmap and vector font rendering

• SQLite - a powerful and lightweight relational database engine


available to all applications
Android Runtime

• Android includes a set of core libraries that provides most of


the functionality available in the core libraries of the Java
programming language.

• 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.
Android Runtime

Android’s programs are written in Java, using Java-oriented IDEs


like Eclipse

It just doesn’t compile the java code into java bytecode but
instead Dalvik bytecode (.dex)
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

Application Framework

• 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
• Package Manager - shows all the applications installed on
your device
• Telephony Manager - For all Calls/SMS/MMS managing
Applications

Android will ship with a set of core applications including an


email client, SMS program, calendar, maps, browser, contacts, and
others. All applications are written using the Java programming
language.
Application Fundamentals

Android applications are written in the Java programming language.

The compiled Java code — along with any data and resource files required by the
application — is bundled by the aapt tool into an Android package, an archive file
marked by an .apk suffix

. This file is the vehicle for distributing the application and installing it on mobile
devices; it's the file users download to their devices. All the code in a single .apk
file is considered to be one application.

In many ways, each Android application lives in its own world:

• By default, every application runs in its own Linux process.

• 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.
The AndroidManifest.xml File

Every application must have an AndroidManifest.xml file (with


precisely that name) in its root directory.

The manifest presents essential information about the


application to the Android system, information the system must
have before it can run any of the application's code.
The AndroidManifest.xml File
It names the Java package for the application. The package name
serves as a unique identifier for the application.

It determines which processes will host application components.

It declares which permissions the application must have in order to access protected
parts of the API and interact with other applications.

It also declares the permissions that others are required to have in order to
interact with the application's components.

It lists the Instrumentation classes that provide profiling and other information as
the application is running. These declarations are present in the manifest only while the
application is being developed and tested; they're removed before the application is
published.

It declares the minimum level of the Android API that the application
requires.

It lists the libraries that the application must be linked against.


Resources and Assets

Resources are an integral part of an Android application.

In general, these are external elements that you want to include and
reference within your application, like images, audio, video, text strings,
layouts, themes, etc.
UI Guideliness
UI Guideliness
Preparing to Publish: A Checklist
Before you consider your application ready for release:

1. Test your application extensively on an actual device

2. Consider adding an End User License Agreement in your application

3. Specify an icon and label in the application's manifest

4. Turn off logging and debugging and clean up data/files

Before you do the final compile of your application:

1. Version your application

2. Obtain a suitable cryptographic key

3. Register for a Maps API Key, if your application is using MapView elements

Compile your application...

After compiling your application:

1. Sign your application

2. Test your compiled application


Publish
To register as an Android Market developer and get started with publishing, visit the
Android Market:

http://market.android.com/publish

If you plan to publish your application on Android Market, you must make sure that it
meets the requirements listed below, which are enforced by the Market server when
you upload the application.

Requirements enforced by the Android Market server:

1. Your application must be signed with a cryptographic private key whose


validity period ends after 22 October 2033.

2. Your application must define both an android:versionCode and an


android:versionName attribute in the <manifest> element of its manifest. The
server uses the android:versionCode as the basis for identifying the application
internally and handling upgrades, and it displays the android:versionName to users as
the application's version.

3. Your application must define both an android:icon and an


android:label attribute in the <application> element of its manifest.
Hello, World
• Before you can launch the emulator, you must create
an Android Virtual Device (AVD). An AVD defines
the system image and device settings used by the
emulator.

• Create an AVD
To create an AVD, use the "android" tool provided in
the Android SDK. Open a command prompt or
terminal, navigate to the tools/ directory in the SDK
package and execute:
android create avd --target 2 --name my_avd
Hello, World- Create a New Android Project

Fill in the project details with the following values:


• Project name: HelloAndroid
• Application name: Hello, Android
• Package name: com.example.helloandroid (or
your own private namespace)
• Create Activity: HelloAndroid
• Min SDK Version: 2
Hello, World- Construct the UI
package com.android.helloandroid;

import android.app.Activity;

import android.os.Bundle;

import android.widget.TextView;

public class HelloAndroid extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

TextView tv = new TextView(this);

tv.setText("Hello, Android");

setContentView(tv);

}
Thank you !

Você também pode gostar