1.androidintro
TRANSCRIPT
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 1/82
Android
Mengenal AndroidOleh: Pius Anggoro
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 2/82
Topik
1. Apakah ANDROID itu?2. Asal mula ANDROID3. Perangkat yang menggunakan ANDROID4. Versi ANDROID5. Arsitektur ANDROID6. Aplikasi di ANDROID
7. Membangun aplikasi ANDROID
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 3/82
Topik
1. Apakah ANDROID itu?2. Asal mula ANDROID3. Perangkat yang menggunakan ANDROID4. Versi ANDROID5. Arsitektur ANDROID6. Aplikasi di ANDROID
7. Membangun aplikasi ANDROID
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 4/82
Apakah ANDROID itu?
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 5/82
Apakah ANDROID itu?
• Android merupakan sekumpulan software untuk perangkat bergerak ( mobile device ) yang
di dalamnya, terdapat:sistem operasi,middleware ,key applications
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 6/82
• Berdasarkan kernel sistem operasi Linux untukmenyediakan layanan sistem:
Manajemen ProsesManajemen MemoriManajemen DayaDriver HardwareKeamanan
• Dikembangkan oleh Google yang kemudianberkolaborasi dengan ” the Open Handset Alliance(OHA) ”
Apakah ANDROID itu?
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 7/82
the Open Handset Alliance (OHA)?konsorsium dari beberapa perusahaan
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 8/82
Topik
1. Apakah ANDROID itu?2. Asal mula ANDROID3. Perangkat yang menggunakan ANDROID
4. Versi ANDROID5. Arsitektur ANDROID6. Aplikasi di ANDROID
7. Membangun aplikasi ANDROID
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 9/82
• 2005, Google meng-akusisi perusahaan Android Inc. untukmemulai mengembangkan platform Android
• 2007, sekelompok pemimpin industri datang bersama membentukOpen Handset Alliance (http://www.openhandsetalliance.com )
• November 2007, Android SDK dirilis pertama kali dengan “tampilanawal” ( early look )
• September 2008, T-Mobile mengumumkan ketersediaan HTCDream 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 ” Apache’s open source license ”
Asal mula ANDROID
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 10/82
Asal mula ANDROID
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 11/82
Topik
1. Apakah ANDROID itu?2. Asal mula ANDROID3. Perangkat yang menggunakan ANDROID
4. Versi ANDROID5. Arsitektur ANDROID6. Aplikasi di ANDROID
7. Membangun aplikasi ANDROID
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 12/82
HTC Dream G1
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 13/82
Phones
HTC G1,Droid,Tattoo
Motorola Droid (X)
Suno S880 Samsung Galaxy Sony Ericsson
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 14/82
Phones
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 15/82
Tablets
Velocity Micro Cruz Gome FlyTouch Acer beTouch
Dawa D7
Toshiba AndroidSmartBook
Cisco Android Tablet
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 16/82
Tablets
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 17/82
Android Watch
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 18/82
Samsung Galaxy Camera
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 19/82
Android-Powered Microwave
By Touch Revolution – at CES 2010
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 20/82
Topik
1. Apakah ANDROID itu?2. Asal mula ANDROID3. Perangkat yang menggunakan ANDROID
4. Versi ANDROID5. Arsitektur ANDROID6. Aplikasi di ANDROID7. Membangun aplikasi ANDROID
A d id R l
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 21/82
Android ReleasesVersi ANDROID
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 22/82
2009SDK 1.5 (Cupcake)+ New soft keyboard with “autocomplete” featureSDK 1.6 (Donut)
+ Support Wide VGASDK 2.0/2.0.1/2.1 (Eclair)+ Revamped UI, browser
2010
SDK 2.2 (Froyo)+ Flash support, tetheringSDK 2.3 (Gingerbread)+ UI update, system-wide copy-paste
Versi ANDROID
GingerbreadAndroid 2.3.+
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 23/82
HoneycombAndroid 3.0-3.2
2011SDK 3.0/3.1/3.2 (Honeycomb) for tablets only+ New UI for tablets, support multi-core processorsSDK 4.0/4.0.1/4.0.2/4.0.3 (Ice Cream Sandwich)+ Changes to the UI, Voice input, NFC
2012SDK 4.1 (Jelly Bean)
Ice cream SandwichAndroid 4.0+
Versi ANDROID
Jelly BeanAndroid 4.1+
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 24/82
Data dikumpulkan selama 2 minggu sebelum tanggal 3 Januari 2012
Versi ANDROID
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 25/82
Topik
1. Apakah ANDROID itu?2. Asal mula ANDROID3. Perangkat yang menggunakan ANDROID
4. Versi ANDROID5. Arsitektur ANDROID6. Aplikasi di ANDROID7. Membangun aplikasi ANDROID
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 26/82
Arsitektur Android
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 27/82
Arsitektur Android
• Relying on Linux Kernel 2.6 for core system servicesMemory and Process ManagementNetwork Stack
Driver ModelSecurity
• Providing an abstraction layer between the hardware
and the rest of the software stack
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 28/82
Arsitektur Android
• Including a set of C/C++ libraries used by components of the Android system
• Exposed to developers through the Android applicationframework
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 29/82
Arsitektur Android
• Core LibrariesProviding most of the functionality available in thecore libraries of the Java language
APIs• Data Structures• Utilities• File Access• Network Access• Graphics• ...
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 30/82
• Dalvik Virtual MachineProviding environment on which every Androidapplication 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
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 31/82
Arsitektur Android
• Enabling and simplifying the reuse of componentsDevelopers have full access to the same framework
APIs used by the core applications.Users are allowed to replace components.
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 32/82
Feature Role
ViewSystem
Used to build an application, including lists, grids, textboxes, buttons, and embedded web browser
ContentProvider Enabling applications to access data from otherapplications or to share their own data
ResourceManager
Providing access to non-code resources (localized strings,graphics, and layout files)
Notification Manager
Enabling all applications to display customer alerts in thestatus bar
ActivityManager
Managing the lifecycle of applications and providinga common navigation backstack
Arsitektur Android
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 33/82
• Activitiesapplication presentation layer
• Servicesinvisible components, update data sources, visible activities, trigger notificationsperform regular processing even when app is not active or invisible
• Content Providersshareable data store
• Intentsmessage passing frameworkbroadcase messages system wide, for an action to be performed
• Broadcast receiversconsume intent broadcastslets app listen for intents matching a specific criteria like location
• NotificationsToast notificationStatus Bar NotificationDialog notification
Arsitektur Android
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 34/82
Arsitektur Android
• Android provides a set of core applications:Email ClientSMS ProgramCalendar MapsBrowser Contacts...
• All applications are written using the Java language.
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 35/82
Topik
1. Apakah ANDROID itu?2. Asal mula ANDROID3. Perangkat yang menggunakan ANDROID
4. Versi ANDROID5. Arsitektur ANDROID6. Aplikasi di ANDROID7. Membangun aplikasi ANDROID
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 36/82
Aplikasi Android
Suatu aplikasi yang berjalan di atas perangkatbergerak dengan platform Android
JenisAplikasi Web : berjalan di dalam sebuah web browser
HTML5, JavaScript, FlashNative : dalam bentuk binaries yang diinstal keperangkat bergerak
Java ME, C/C++
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 37/82
Sejumlah keuntungan bahwa Google Android menjadi perangkatlunak yang open source, antara lain:
Pengguna dapat mengkostumisasi perangkat bergerak denganplatform Google Android yang dimilikinyaKonsumen mendapatkan keuntungan dengan memiliki berbagai
jenis aplikasi mobile untuk dipilihBanyak ponsel yang menggunakan Google Android, sehinggamuncul produk aplikasi yang inovatif Fungsi hiburan dijalankan di atas platform Google Android mampu
menawarkan permainan multiplayer, online, real time, dan lebihrealistikSemakin banyak programmer yang mengembangkan platformGoogle Android
Keuntungan Android Open Source
Mobile Devices: Advantages
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 38/82
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
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 39/82
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
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 40/82
WHAT MAKES ANDROID SPECIAL?
Truly open, free development platformLinux based
Component-based architectureReusable, replaceable modules
Multi-layer isolation of programsMany services includedHigh quality graphics and sound
Portability across hardwareJava programs executed by Davlik virtual machineARM, x86 and other
Support by multiple large organizations
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 41/82
Topik
1. Apakah ANDROID itu?2. Asal mula ANDROID3. Perangkat yang menggunakan ANDROID
4. Versi ANDROID5. Arsitektur ANDROID6. Aplikasi di ANDROID7. Membangun aplikasi ANDROID
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 42/82
Eclipse IDE + ADT (Android Development Tools)• Reduces Development and Testing Time• Makes User Interface-Creation easier • Makes Application Description Easier
Java SDKAndroid 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?
Lingkungan Pengembangan Aplikasi
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 43/82
www.android-x86.org
d id i d i
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 44/82
www.android-indonesia.com
h //b i i d
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 45/82
http://beta.appinventor.mit.edu
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 46/82
for PROGRAMMER / DEVELOPER ?
http://developer android com
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 47/82
http://developer.android.com
da de elopers com
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 48/82
www.xda-developers.com
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 49/82
• Developmentprocess for anAndroid app
SOFTWARE DEVELOPMENT
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 50/82
SOFTWARE DEVELOPMENT
Design Testing
Release Process
Errors?DesignError?
No
Yes
No
Yes
Android Apps
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 51/82
Android Apps
• Built using Java and new SDK librariesNo support for some Java libraries like Swing & AWTOracle 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
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 52/82
Building and running
• ADB is a client server program that connects clients ondeveloper machine to devices/emulators to facilitatedevelopment.
• An IDE like Eclipse handles this entire process for you.
Compiled resources(xml files)
Android Debug Bridge
Applications Are Boxed
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 53/82
Applications Are Boxed
• By default, each app is run in its own Linux processProcess started when app‟s code needs to be executedThreads can be started to handle time-consumingoperations
• Each process has its own Dalvik VM
• By default, each app is assigned unique Linux ID
Permissions are set to app‟s files are only visibleto that app
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 54/82
Android Market Google Play
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 55/82
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
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 56/82
Publishing to Google Play
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 57/82
Publishing to Google Play
• Requires Google Developer Account$25 fee
• Link to a Merchant Account
Google CheckoutLink to your checking accountGoogle takes 30% of app purchase price
RELEASE PROCESS
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 58/82
RELEASE PROCESS
Prepare for BuildPerform Build
“Release Candidate”ThoroughlyTest Build
PublishRelease
Test PackagedRelease Candidate
Package andSign Package
Fix Bugs! yes
Got Bugs?No Bugs?
Bugs?
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 59/82
Android Design Philosophy
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 60/82
g p y
• Applications should be:Fast
• Resource constraints: <200MB RAM, slow processor Responsive
• Apps must respond to user actions within 5 secondsSecure
• Apps declare permissions in manifestSeamless
• Usability is key, persist data, suspend services• Android kills processes in background as needed
IMPLEMENTATION
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 61/82
IMPLEMENTATION
Cheap : Install the toolsJava, Eclipse, Android SDKYour computer: Windows, Linux, MacPhone emulator included
Easy : Create your first programAndroid Development Toolkit (ADT)Plugin for Eclipse, written by GoogleExamples and tutorials available
Run on the EmulatorVerify by USB connecting a phone to computer
Rewarding : Prepare to publish eg. Google Market
Application Building Blocks
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 62/82
pp g
• Activity• IntentReceiver • Service
• ContentProvider
Activities
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 63/82
• Typically correspond to one UI screen• But, they can:
– Be faceless
– Be in a floating window – Return a value
Intent Receivers
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 64/82
• Components that respond to broadcast „Intents‟• Way to respond to external notification or alarms• Apps can invent and broadcast their own Intent
Intents
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 65/82
• Think of Intents as a verb and object; a descriptionof what you want done – E.g.: VIEW, CALL, PLAY, etc..
• System matches Intent with Activity that can bestprovide the service
• Activities and IntentReceivers describe whatIntents they can service
Services
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 66/82
• Faceless components that run in the background – E.g.: music player, network download, etc…
Content Providers
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 67/82
• 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
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 68/82
• Android apps do not have control over their ownlife cycles• Aggressively manages resources to ensure device
responsiveness and kills process/apps whenneeded
• Active Process – critical priority• Visible Process – high priority• Service Process – normal priority• Background Process – low priority• Empty process
Applications
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 69/82
• All apps (native and 3 rd party) are written using thesame APIs and run on the same run timeexecutable
• All apps have APIs for:hardware access, location-based services, supportfor background services, map-based activities, 2Dand 3D graphics.
• App Widgets are miniature app views that can beembedded in other apps like Home Screen
Client apps
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 70/82
• Developed using the Android SDK and installed onuser 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 itsroot directory – provides essential information about app
• Could be installed directly on phone,but necessary to be distributed thru Market
Web Apps
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 71/82
• 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
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 72/82
• Activity : single screen with a UI, somewhatanalogous 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 inthe UI
Android UI
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 73/82
• 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
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 74/82
• UI construction can be done in three ways:1. Programmatic, like hand-coded Java desktop GUI
construction2. Declarative hand-written, like Java web UI
construction XML3. Declarative with a GUI builder, like .NET UI
construction then GUI builder generates the XML
Programmatic UI
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 75/82
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
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 76/82
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
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 77/82
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
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 78/82
DEVELOPMENT FEATURES 1
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 79/82
MultimediaAudio and video playback and record ability will benative in the devices. Interrogate these and use asdesired eg. video recording, music playback,
microphone for audio notes.
NetworkMost Android devices will be Internet ready. The net canbe accessed at any desired level, from Java sockets tothe integral WebKit-based web browser which can beembedded into your apps.
DEVELOPMENT FEATURES 2
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 80/82
Storage
Global positioning system (GPS)Many devices will have GPS receiver to dtermine
location. This location data can be used in navigationas well as triggering activities.
Phone servicesAll phone services eg. Initiate and receive calls, shortmessages, data transmittals
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 81/82
Ada pertanyaan?
7/30/2019 1.AndroidIntro
http://slidepdf.com/reader/full/1androidintro 82/82
Terima Kasih