presentation android
DESCRIPTION
Présentation & Introduction à Android - Nouveau système d'exploitation mobile lancé par Google.TRANSCRIPT
Introduction à Android by Jean Collas, Ghislain Deffrasne, Reda Sebbani is licensed
under a Creative Commons Attribution 2.0 France License. Original at http://www.jean-collas.fr/android
Ouverture
Jean Collas, Réda Sebbani, Ghislain Deffrasnes
ContexteContexte
Téléphonie Mobile : Smart Phone
40 millions de smartphones / trimestre (2008)
Chiffre d’affaire énorme
Développement logiciel pour mobiles
iPhone OS
Windows Mobile
RIM
Symbian
Contexte Concurrentiel
0%
10%
20%
30%
40%
50%
60%
70%
2007
2008
Systèmes d’exploitation pour Smart phone :
Marché en constante augmentation (+28% en 1 an, 31M -> 40M)Possibilités d’évolution énormes avec un bon produit
Internet & Google
Fondé en 98, croissance constante
Attaque du monde mobile par la source : le système d’exploitation Android
Politique de financement par la publicité
Multiples domaines de l’informatique :Recherche, cartographie, vidéo, conception 3D, suite bureautique, publicité, navigateur, …
Points forts d’AndroidPoints fort d’Android
Point de vue constructeur
Système Linux + Java
Point de vue utilisateur
Système fonctionnel, intuitif, évolutif
Point de vue développeur
Application développées en syntaxe Java
SDK complet fourni
Point de vue bidouilleur
Projet Open Source C++ / Java
Start-up AndroidAoût 2005
Android MarketAoût 2008
Android 1.0 et SDK release 1 Septembre 2008
T-Mobile G1
Android : Open SourceOctobre 2008
Avril 2008
DeveloperChallenge
Novembre 2007Annonce d’Android
Open Handset Alliance
SDK pour Android
Développementd’Android
Android 1.0 et SDK release 2 Novembre 2008
Historique
Historique
Consortium créé fin 2007
Open Handset Alliance
Entreprises de commercialisationFabricants d'appareils mobiles
Opérateurs de téléphonie mobileFabricants de semi-conducteurs
Fabricants de logiciels
47 compagnies
But : développer des normes ouvertes pour les appareils de téléphonie mobile
T-Mobile G1
1er téléphone avec Android
De 180 à 400 $
Wi-fi et Bluetooth
GPS
Accéléromètres
Caméra
Écran tactile
T-Mobile G1 (HTC)
LG
L’agora par Kogan
De nouveaux mobiles
Preuve de sa portabilité – Futur d’Android
Et si Android n’était pas seulement conçu pour les smartphone?
Android sur un NetBook
Barre de recherche « Google Search »
Gmail
Google Talk (IM)
Navigateur Web
Gmaps
Google StreetView
Intégration des applications Google
Google Maps
Orientation
AchatsCovoiturage
Travail
Tourisme
Voyage
VoisinageGéolocalisation
Géolocalisation
Exemples d’applications : Android Market
Points d’accès d’Android
Point de vue constructeur
Système Linux + Java
Point de vue utilisateur
Système fonctionnel, intuitif, évolutif
Point de vue développeur
Application développées en syntaxe Java
SDK complet fourni
Point de vue bidouilleur
Projet Open Source C++ / Java
ANDROID RUNTIME
APPLICATION FRAMEWORK
APPLICATIONS
LINUX KERNEL
Core Libraries
Dalvik Virtual Machine
LIBRARIESSurface Manager Media Framework SQL Lite
OpenGL Audio Manager WebKit
SGL SSL Libc
Display Driver
Keypad Driver
Camera Driver
WiFi Driver
Flash Memory Driver
Audio Driver
Binder (IPC) Driver
Power Management
Activity Manager Window Manager Content Providers View System
Package Manager
TelephonyManager
Resource Manager
Location Manager
Notification Manager
Home Contacts Phone Browser …
Architecture
JNI
LINUX KERNEL
Display Driver
Keypad Driver
Camera Driver
WiFi Driver
Flash Memory Driver
Audio Driver
Binder (IPC) Driver
Power Management
Noyau d’Android
HARDWARE ABSTRACTION LAYERGraphics Audio Camera Bluetooth GPS WiFi …
Architecture ARMBasé sur Linux 2.6.24
Système de fichiers supporté : FAT32Support de TCP/IP, UDP,…
Adaptation aux besoins du mobile
• Alarm : timers pour « réveiller » des périphériques• Ashmem : partage de mémoire entre processus• Binder : driver IPC pour la communication inter-processus• Power Management• Low Memory Killer• Kernel Debugger• Logger
LINUX KERNEL
Display Driver
Keypad Driver
Camera Driver
WiFi Driver
Flash Memory Driver
Audio Driver
Binder (IPC) Driver
Power Management
HARDWARE ABSTRACTION LAYERGraphics Audio Camera Bluetooth GPS WiFi …
Librairies
LIBRARIESSurface Manager Media Framework SQL Lite
OpenGL Audio Manager WebKit
SGL SSL Libc
LINUX KERNEL
Display Driver
Keypad Driver
Camera Driver
WiFi Driver
Flash Memory Driver
Audio Driver
Binder (IPC) Driver
Power Management
Application 1
Application 2
Surface Manager
Surface Flinger
Écran(Frame Buffer)
Audio Manager
Audio Flinger
OreilletteSonnerie d’appel
Lecteur MP3 Écouteurs
ANDROID RUNTIME
Core Libraries
Dalvik Virtual Machine
Machine Virtuelle Dalvik
LIBRARIESSurface Manager Media Framework SQL Lite
OpenGL Audio Manager WebKit
SGL SSL Libc
LINUX KERNEL
Display Driver
Keypad Driver
Camera Driver
WiFi Driver
Flash Memory Driver
Audio Driver
Binder (IPC) Driver
Power Management
Machine Virtuelle Dalvik
Exécute des fichiers .dex (Dalvik Executable)
Nouvelle instance pour chaque processus : Applications indépendantes
Dalvik core class library fournit une base de développement proche de java SE, adapté au mobile
ANDROID RUNTIME
Core Libraries
Dalvik Virtual Machine
LIBRARIESSurface Manager Media Framework SQL Lite
OpenGL Audio Manager WebKit
SGL SSL Libc
Framework & fondations des applications
LINUX KERNEL
Display Driver
Keypad Driver
Camera Driver
WiFi Driver
Flash Memory Driver
Audio Driver
Binder (IPC) Driver
Power Management
APPLICATION FRAMEWORK
JNI
Activity Manager Window Manager Content Providers View System
Package Manager
TelephonyManager
Resource Manager
Location Manager
Notification Manager
Décrit par : Une action (VIEW, EDIT, MAIN,…) La donnée à traiter (sous forme d’URI)
Intents
Intent : Requête; Description d’une action à effectuer Fait le lien entre différentes applications
Types d’Intent : Explicite (référence exacte) Implicite (description)
Intents
Intent 1 App.AIntent 2 App.B
.
.
Messagerie Contacts
StartActivity(View Contact)
Intent Resolver
Echange
Publication
IntentFilterVIEWEDIT
12
3
Edit ContactContactsView Contact Contacts
Intent Filter
<intent-filter>
<action android:value="android.intent.action.VIEW" />
<action android:value="android.intent.action.EDIT" />
<action android:value="android.intent.action.PICK" />
<category android:value="android.intent.category.DEFAULT" />
<type
android:value="vnd.android.cursor.dir/vnd.google.contact" />
</intent-filter>
Objectif : Description du handler
IntentFilter décrivent les capacités de l’application.
Publication d’IntentFilters par les activités
void startActivity(Intent intent) ;void sendBroadcast(Intent intent)boolean bindService(Intent service, int flags)ComponentName startService(Intent service)
Les URIs - Utilisation
125people///contacts/content:
&cbp=1,yaw,,pitch,zoom
Exemples d’URI:
25,32geo:VIEW_ACTION
Intent
EDIT_ACTION
CALL_ACTION
Ouvre l’application de géo-localisation à la position donnée (latitude, longitude).
123tel: Appelle le numéro 123
VIEW_ACTION cbll=25,32google.streetview:
Notification Manager
Applications peuvent s’exécuter simultanément
Différentes formes de notifications :- LED- Son- Vibreur- Barre de notification (icône)
Notifications d’événements du background
Barre de notifications
Mise en place facilité par le Notification Manager
Composants d’une application
Activity
ServiceContent Provider
Broadcast Receiver
SYSTEMAPK APK
Remotedata
SQLiteData
XML
Activity Activity serviceActivity
Content Provider
service
SYSTEMAPK APK
Remotedata
SQLiteData
XML
Activity Activity serviceActivity
Content Provider
service
ContentProvider
Les URIs
Activity
ServiceContent Provider
IntentReceiver
Exemples d’URI d’un content provider:
0 ou plusieurs segments, permettent de déterminer le type de données C
Enregistrement spécifique éventuellement demandé (identifiant, référence)D
Préfixe d’accès aux données, type d’URIA
Identifiant ou type du content provider à consulterB
125people///contacts/content:
53users///com.maCompanie.monApp/content:
<provider class=".NotePadProvider"android:authorities="com.google.provider.NotePad" />
Content Provider
Content Providers
Activity
ServiceContent Provider
IntentReceiver
Contacts
Browser
MediaStore.Images
MediaStore.Audio
Settings
Applications
Lecteur MP3
URI
Annuaire
Résultat
ContentResolver+ delete()+ insert()+ notifyChange()+ query()+ update()
//contacts/ 125people/content:URI :
Activity
Activity
ServiceContent Provider
IntentReceiverObjet qui possède un cycle de vie
Généralement, une Activity affiche une UI
Point d’entrée d’une application
Code qui réalise un traitement
<activity class=".NoteEditor" android:label="@string/title_note">
<intent-filter android:label="@string/resolve_edit">
<action android:value="android.intent.action.VIEW" />
<action android:value="android.intent.action.EDIT" />
<category android:value="android.intent.category.DEFAULT" />
<type android:value="vnd.android.cursor.item/vnd.google.note" />
</intent-filter>
</activity>
Broadcast receiver
Activity
ServiceContent Provider
Broadcast
Receiver
.
Broadcast receiver permet de réagir à des évènements extérieurs à l’application
Permet également de réagir à des notification du système (évènements extérieurs/matériels).
Un Intent peut être boadcasté; on peut utiliser un broadcast receiver pour gérer ce type d’evt
Permet de réveiller une application
<receiver android:name=".app.OneShotAlarm" android:process=":remote" />
Service
Activity
ServiceContent Provider
IntentReceiver
Composante sans GUIActivité de longue durée
Service interne : Context.startService()Service externe : Context.bindService()
Communication via une interfaceEx Media Player : pause, lecture, stop, etc
<service android:name=".app.RemoteService" android:process=":remote">
<intent-filter>
<!-- These are the interfaces supported by the service, which
you can bind to. -->
<action android:name="com.example.android.apis.app.IRemoteService" />
<!-- This is an action code you can use to select the service
without explicitly supplying the implementation class. -->
<action android:name="com.example.android.apis.app.REMOTE_SERVICE" />
</intent-filter>
</service>
Service : AndroidManifest
Activity
ServiceContent Provider
IntentReceiver
AndroidManifest complet
Activity
IntentReceiver
Service
Content Provider
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.notepad">
<application android:icon="@drawable/app_notes" android:label="@string/app_name">
<activity class=".NotesList" android:label="@string/title_notes_list">
<intent-filter>
<action android:value="android.intent.action.MAIN" />
<category android:value="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider class=".NotePadProvider" android:authorities="com.google.provider.NotePad"/>
<service android:name=".app.RemoteService" android:process=":remote">
<intent-filter>
<action android:name="com.example.android.apis.app.IRemoteService" />
</intent-filter>
</service>
<receiver android:name=".app.OneShotAlarm" android:process=":remote" />
</application>
</manifest>
OnCreate() Allocation des ressources
OnStart() Affichage à l’écran
OnResume() Passage au premier plan
OnPause() Passage en arrière plan
OnStop() Arrêt de l’exécution
OnDestroy() Libération des ressources
Cycle de vie d’une Activité
Activity
ServiceContent Provider
IntentReceiver
Running
Paused
Stopped
Killed
Cycle de vie d’une Activité
New Activity
Running(Foreground)
1. OnCreate()2. OnStart()3. OnResume()
Paused(Background)
OnFreeze()OnPause()
OnResume()
Destroyed
OnDestroy()
3. OnResume()2. OnStart()1. OnRestart()
ApplicationKilled
Retour à l’application
Stopped(Plus visible)
OnStop()Application plus visible
L’utilisateur quitte
Besoin de mémoire
Hiérarchie des processus
Empty Process
Background Process
Service Process
Visible Process
Foreground Process
Imp
ort
ance
Cache pour les processus
Processus en arrière plan, non visible.
Processus des composants « Service » disponibles en arrière plan
Activité en arrière plan
Activité
Hiérarchie des processus
ANDROID RUNTIME
Core Libraries
Dalvik Virtual Machine
LIBRARIESSurface Manager Media Framework SQL Lite
OpenGL Audio Manager WebKit
SGL SSL Libc
Les applications
LINUX KERNEL
Display Driver
Keypad Driver
Camera Driver
WiFi Driver
Flash Memory Driver
Audio Driver
Binder (IPC) Driver
Power Management
APPLICATION FRAMEWORK
JNI
Activity Manager Window Manager Content Providers View System
Package Manager
TelephonyManager
Resource Manager
Location Manager
Notification Manager
APPLICATIONS
Home Contacts Phone Browser …
package com.android.hello;
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);
}
}
JAVA(uniquement)
1 champ de texte
HelloAndroid.java
Développement en Java : Méthode classique
JAVAmétier
XML vues
package com.android.hello;
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);
setContentView(R.layout.main);
}
}
HelloAndroid.java
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/hello"/> main.xml
Séparation Présentation / Métier
package com.android.hello;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
main.xmlDescription du layout
strings.xml
icon.png
Étiquettes Texte
Image
Description du layoutR.java
Interfaçage des ressources
Génération automatique
.java .class
Sources
.png
.xml
Ressources + Manifest
.dex
.apk
Byte-code (optimisé)
Application compilée
Compilation et Déploiement d’une Application
/data/app/
HelloWorld
Vidéos StreetView + Compass
Vidéos StreetView + Compass
?
Vidéo StreetView + Compass
Vidéo StreetView + Compass
Booter Android