Anda di halaman 1dari 82

Android

Oleh: Pius Anggoro

Mengenal Android

ANDROID

Topik
1. 2. 3. 4. 5. 6. 7. Apakah ANDROID itu? Asal mula ANDROID Perangkat yang menggunakan ANDROID Versi ANDROID Arsitektur ANDROID Aplikasi di ANDROID Membangun aplikasi ANDROID

Topik
1. 2. 3. 4. 5. 6. 7. Apakah ANDROID itu? Asal mula ANDROID Perangkat yang menggunakan ANDROID Versi ANDROID Arsitektur ANDROID Aplikasi di ANDROID Membangun aplikasi ANDROID

Apakah ANDROID itu?

Apakah ANDROID itu?

Android merupakan sekumpulan software untuk perangkat bergerak (mobile device) yang di dalamnya, terdapat: sistem operasi, middleware, key applications

Apakah ANDROID itu?


Berdasarkan kernel sistem operasi Linux untuk menyediakan layanan sistem: Manajemen Proses Manajemen Memori Manajemen Daya Driver Hardware Keamanan Dikembangkan oleh Google yang kemudian berkolaborasi dengan the Open Handset Alliance (OHA)

the Open Handset Alliance (OHA)?


konsorsium dari beberapa perusahaan

Topik
1. 2. 3. 4. 5. 6. 7. Apakah ANDROID itu? Asal mula ANDROID Perangkat yang menggunakan ANDROID Versi ANDROID Arsitektur ANDROID Aplikasi di ANDROID Membangun aplikasi ANDROID

Asal mula ANDROID


2005, Google meng-akusisi perusahaan Android Inc. untuk memulai mengembangkan platform Android 2007, sekelompok pemimpin industri datang bersama membentuk Open Handset Alliance (http://www.openhandsetalliance.com) November 2007, Android SDK dirilis pertama kali dengan tampilan awal (early look) September 2008, T-Mobile mengumumkan ketersediaan HTC Dream G1, smartphone pertama yang berbasiskan platform Android. Beberapa hari berikutnya Google mengumumkan ketersediaan Android SDK Release Candidate 1.0

Oktober 2008, Google membuat kode program dari platform Android tersedia di bawah Apaches open source license

Asal mula ANDROID

Topik
1. 2. 3. 4. 5. 6. 7. Apakah ANDROID itu? Asal mula ANDROID Perangkat yang menggunakan ANDROID Versi ANDROID Arsitektur ANDROID Aplikasi di ANDROID Membangun aplikasi ANDROID

HTC Dream G1

Phones

HTC G1, Droid, Tattoo

Motorola Droid (X)

Suno S880

Samsung Galaxy

Sony Ericsson

Phones

Tablets

Velocity Micro Cruz

Gome FlyTouch

Acer beTouch

Dawa D7

Toshiba Android SmartBook

Cisco Android Tablet

Tablets

Android Watch

Samsung Galaxy Camera

Android-Powered Microwave

By Touch Revolution at CES 2010

Topik
1. 2. 3. 4. 5. 6. 7. Apakah ANDROID itu? Asal mula ANDROID Perangkat yang menggunakan ANDROID Versi ANDROID Arsitektur ANDROID Aplikasi di ANDROID Membangun aplikasi ANDROID

Versi ANDROID

Android Releases

Versi ANDROID
2009 SDK 1.5 (Cupcake) + New soft keyboard with autocomplete feature SDK 1.6 (Donut) + Support Wide VGA SDK 2.0/2.0.1/2.1 (Eclair) + Revamped UI, browser 2010 SDK 2.2 (Froyo) + Flash support, tethering SDK 2.3 (Gingerbread) + UI update, system-wide copy-paste Gingerbread
Android 2.3.+

Versi ANDROID
2011 SDK 3.0/3.1/3.2 (Honeycomb) for tablets only + New UI for tablets, support multi-core processors SDK 4.0/4.0.1/4.0.2/4.0.3 (Ice Cream Sandwich) + Changes to the UI, Voice input, NFC 2012 SDK 4.1 (Jelly Bean)

Honeycomb
Android 3.0-3.2

Ice cream Sandwich Jelly Bean


Android 4.0+ Android 4.1+

Versi ANDROID

Data dikumpulkan selama 2 minggu sebelum tanggal 3 Januari 2012

Topik
1. 2. 3. 4. 5. 6. 7. Apakah ANDROID itu? Asal mula ANDROID Perangkat yang menggunakan ANDROID Versi ANDROID Arsitektur ANDROID Aplikasi di ANDROID Membangun aplikasi ANDROID

Arsitektur Android

Arsitektur Android

Relying on Linux Kernel 2.6 for core system services


Memory and Process Management Network Stack Driver Model Security

Providing an abstraction layer between the hardware and the rest of the software stack

Arsitektur Android
Including a set of C/C++ libraries used by components of the Android system Exposed to developers through the Android application framework

Arsitektur Android
Core Libraries Providing most of the functionality available in the core libraries of the Java language APIs Data Structures Utilities File Access Network Access Graphics ...

Arsitektur Android
Dalvik Virtual Machine Providing environment on which every Android application runs Each Android application runs in its own process, with its own instance of the Dalvik VM. Dalvik has been written such that a device can run multiple VMs efficiently. Register-based virtual machine

Arsitektur Android

Enabling and simplifying the reuse of components Developers have full access to the same framework APIs used by the core applications. Users are allowed to replace components.

Arsitektur Android
Feature View System Content Provider Resource Manager Role Used to build an application, including lists, grids, text boxes, buttons, and embedded web browser Enabling applications to access data from other applications or to share their own data Providing access to non-code resources (localized strings, graphics, and layout files)

Notificatio Enabling all applications to display customer alerts in the n Manager status bar Activity Manager Managing the lifecycle of applications and providing a common navigation backstack

Arsitektur Android
Activities

application presentation layer invisible components, update data sources, visible activities, trigger notifications perform regular processing even when app is not active or invisible shareable data store message passing framework broadcase messages system wide, for an action to be performed consume intent broadcasts lets app listen for intents matching a specific criteria like location Toast notification Status Bar Notification Dialog notification

Services

Content Providers Intents Broadcast receivers Notifications

Arsitektur Android

Android provides a set of core applications: Email Client SMS Program Calendar Maps Browser Contacts ... All applications are written using the Java language.

Topik
1. 2. 3. 4. 5. 6. 7. Apakah ANDROID itu? Asal mula ANDROID Perangkat yang menggunakan ANDROID Versi ANDROID Arsitektur ANDROID Aplikasi di ANDROID Membangun aplikasi ANDROID

Aplikasi Android
Suatu aplikasi yang berjalan di atas perangkat bergerak dengan platform Android Jenis Aplikasi Web : berjalan di dalam sebuah web browser HTML5, JavaScript, Flash Native: dalam bentuk binaries yang diinstal ke perangkat bergerak Java ME, C/C++

Keuntungan Android Open Source


Sejumlah keuntungan bahwa Google Android menjadi perangkat lunak yang open source, antara lain: Pengguna dapat mengkostumisasi perangkat bergerak dengan platform Google Android yang dimilikinya Konsumen mendapatkan keuntungan dengan memiliki berbagai jenis aplikasi mobile untuk dipilih Banyak ponsel yang menggunakan Google Android, sehingga muncul produk aplikasi yang inovatif Fungsi hiburan dijalankan di atas platform Google Android mampu menawarkan permainan multiplayer, online, real time, dan lebih realistik Semakin banyak programmer yang mengembangkan platform Google Android

Mobile Devices: Advantages


(as compared to fixed devices) Always with the user Typically have Internet access Typically GPS enabled Typically have accelerometer & compass Most have camera Always have microphone & speaker(s) Many apps are free or low-cost

Mobile Devices: Disadvantages


Limited screen size Limited battery life Limited processor speed (?) Limited and sometimes slow network access Limited or awkward input: soft keyboard, phone keypad, touch screen, stylus Limited web browser functionality

WHAT MAKES ANDROID SPECIAL?


Truly open, free development platform Linux based Component-based architecture Reusable, replaceable modules Multi-layer isolation of programs Many services included High quality graphics and sound Portability across hardware Java programs executed by Davlik virtual machine ARM, x86 and other Support by multiple large organizations

Topik
1. 2. 3. 4. 5. 6. 7. Apakah ANDROID itu? Asal mula ANDROID Perangkat yang menggunakan ANDROID Versi ANDROID Arsitektur ANDROID Aplikasi di ANDROID Membangun aplikasi ANDROID

Lingkungan Pengembangan Aplikasi


Eclipse IDE + ADT (Android Development Tools) Reduces Development and Testing Time Makes User Interface-Creation easier Makes Application Description Easier Java SDK Android SDK SDK Manager Class Library Developer Tools Emulator and System Images Documentation and Sample Code Harus punya perangkat mobile ANDROID? Harus mahir bahasa pemrograman JAVA?

www.android-x86.org

www.android-indonesia.com

http://beta.appinventor.mit.edu

for PROGRAMMER / DEVELOPER ?

http://developer.android.com

www.xda-developers.com

Development process for an Android app

SOFTWARE DEVELOPMENT

Design

Cd g o in

Testing

No
Yes Design Error? Yes Errors?

No

Release Process

Android Apps
Built using Java and new SDK libraries No support for some Java libraries like Swing & AWT Oracle currently suing Google over use Java code compiled into Dalvik byte code (.dex) Optimized for mobile devices (better memory management, battery utilization, etc.) Dalvik VM runs .dex files

Building and running


Compiled resources (xml files)

Android Debug Bridge

ADB is a client server program that connects clients on developer machine to devices/emulators to facilitate development. An IDE like Eclipse handles this entire process for you.

Applications Are Boxed


By default, each app is run in its own Linux process Process started when apps code needs to be executed Threads can be started to handle time-consuming operations Each process has its own Dalvik VM By default, each app is assigned unique Linux ID Permissions are set to apps files are only visible to that app

Android Market Google Play


Publishing and Monetizing Has various categories, allows ratings Have both free/paid apps Featured apps on web and on phone The Android Market is great for developers Level playing field Allowing third-party apps Revenue sharing

http://play.google.com

Publishing to Google Play


Requires Google Developer Account $25 fee Link to a Merchant Account Google Checkout Link to your checking account Google takes 30% of app purchase price

RELEASE PROCESS
Perform Build Release Candidate Thoroughly Test Build

Prepare for Build

Fix Bugs!

yes

Bugs?

No Bugs? Publish Release

Got Bugs? Package and Sign Package

Test Packaged Release Candidate

Android Design Philosophy


Applications should be: Fast Resource constraints: <200MB RAM, slow processor Responsive Apps must respond to user actions within 5 seconds Secure Apps declare permissions in manifest Seamless Usability is key, persist data, suspend services Android kills processes in background as needed

IMPLEMENTATION

Cheap: Install the tools Java, Eclipse, Android SDK Your computer: Windows, Linux, Mac Phone emulator included Easy: Create your first program Android Development Toolkit (ADT) Plugin for Eclipse, written by Google Examples and tutorials available Run on the Emulator Verify by USB connecting a phone to computer Rewarding: Prepare to publish eg. Google Market

Application Building Blocks


Activity IntentReceiver Service ContentProvider

Activities
Typically correspond to one UI screen But, they can: Be faceless Be in a floating window Return a value

Intent Receivers
Components that respond to broadcast Intents Way to respond to external notification or alarms Apps can invent and broadcast their own Intent

Intents
Think of Intents as a verb and object; a description of what you want done E.g.: VIEW, CALL, PLAY, etc.. System matches Intent with Activity that can best provide the service Activities and IntentReceivers describe what Intents they can service

Services
Faceless components that run in the background E.g.: music player, network download, etc

Content Providers
Enables sharing of data across applications E.g.: address book, photo gallery, etc... Provides uniform APIs for: querying delete, update and insert. Content is represented by URI and MIME type

App Priority and Processes


Android apps do not have control over their own life cycles Aggressively manages resources to ensure device responsiveness and kills process/apps when needed

Active Process critical priority Visible Process high priority Service Process normal priority Background Process low priority Empty process

Applications
All apps (native and 3rd party) are written using the same APIs and run on the same run time executable All apps have APIs for: hardware access, location-based services, support for background services, map-based activities, 2D and 3D graphics. App Widgets are miniature app views that can be embedded in other apps like Home Screen

Client apps
Developed using the Android SDK and installed on user devices Compiled Java code, with data and resource, bundled by Android Asset Packaging Tool (AAPT) into Android package (.apk) All applications have Android Manifest file in its root directory provides essential information about app Could be installed directly on phone, but necessary to be distributed thru Market

Web Apps
An alternative to standalone apps Developed using web standards and accessed through browser nothing to install on devices Mixing client and web apps is also possible Client apps can embed web pages using Webview in Android app

Android UI

Activity: single screen with a UI, somewhat analogous to XAML / code behind pattern in .NET
Email app might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails Implement by subclassing Activity class View: drawable object

Android UI View MVC View


UI contains a hierarchy of Views View is a class, subclassed by the drawable objects in the UI

Android UI
Service: background operation
play music in the background while the user is in a different application fetch data over the network without blocking user interaction with an activity Content Provider: DB or other data access Broadcast Receiver: responds to system messages Battery low

Android UI
UI construction can be done in three ways: 1. Programmatic, like hand-coded Java desktop GUI construction 2. Declarative hand-written, like Java web UI construction XML 3. Declarative with a GUI builder, like .NET UI construction then GUI builder generates the XML

Programmatic UI
package cs454.demo;

import android.app.Activity; import android.widget.TextView; import android.os.Bundle;


public class AndroidDemo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Activity is a subclass of context, so the TextView takes this as a parameter TextView tv = new TextView(this); tv.setText("Hello, CS454"); setContentView(tv); } }

Manual Declarative UI
main.xml Layout File: <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/textview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/hello"/>
strings.xml resource file: <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello Again, CS454!</string> <string name="app_name">CS454 AndroidDemo</string> </resources>

Manual Declarative UI
Java class: package cs454.demo; import android.app.Activity; import android.os.Bundle;

public class AndroidDemo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }

UI With GUI Builder

DEVELOPMENT FEATURES 1

Multimedia Audio and video playback and record ability will be native in the devices. Interrogate these and use as desired eg. video recording, music playback, microphone for audio notes.

Network Most Android devices will be Internet ready. The net can be accessed at any desired level, from Java sockets to the integral WebKit-based web browser which can be embedded into your apps.

DEVELOPMENT FEATURES 2

Storage Global positioning system (GPS) Many devices will have GPS receiver to dtermine location. This location data can be used in navigation as well as triggering activities. Phone services All phone services eg. Initiate and receive calls, short messages, data transmittals

Ada pertanyaan?

Terima Kasih