Applications métiers et/ou d'entreprise sur Windows Phone 7 - bonnes pratique...
Presentation Android
1. 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
3. Contexte
Contexte
Téléphonie Mobile : Smart Phone
Développement logiciel pour mobiles
Chiffre d’affaire énorme
Windows RIM
Mobile
40 millions de smartphones / trimestre (2008)
Symbian
iPhone OS
4. Contexte Concurrentiel
Systèmes d’exploitation pour Smart phone :
70%
60%
50%
40%
30%
20%
10%
0%
2007
2008
Marché en constante augmentation (+28% en 1 an, 31M -> 40M)
Possibilités d’évolution énormes avec un bon produit
5. Internet & Google
Fondé en 98, croissance constante
Multiples domaines de l’informatique :
Recherche, cartographie, vidéo, conception 3D,
suite bureautique, publicité, navigateur, …
Politique de financement par la publicité
Attaque du monde mobile par la source :
le système d’exploitation Android
6. Points forts d’Android
Points fort d’Android
Point de vue constructeur Point de vue utilisateur
Système fonctionnel,
Système Linux + Java
intuitif, évolutif
Point de vue bidouilleur Point de vue développeur
Application développées
Projet Open Source
en syntaxe Java
C++ / Java
SDK complet fourni
7. Historique
Novembre 2008
Android 1.0 et SDK release 2
T-Mobile G1
Octobre 2008
Android : Open Source
Android 1.0 et SDK release 1 Septembre 2008
Android Market
Août 2008
Avril 2008
Developer
Challenge
Open Handset Alliance
Novembre 2007
Annonce d’Android
SDK pour Android
Développement
d’Android
Start-up Android
Août 2005
8. Open Handset Alliance
Consortium créé fin 2007 47 compagnies
Fabricants de semi-conducteurs
Opérateurs de téléphonie mobile
Fabricants d'appareils mobiles Entreprises de commercialisation
Fabricants de logiciels
But : développer des normes ouvertes pour les
appareils de téléphonie mobile
9. T-Mobile G1
T-Mobile G1 (HTC)
1er téléphone avec Android
De 180 à 400 $
Wi-fi et Bluetooth
GPS
Accéléromètres
Caméra
Écran tactile
11. Preuve de sa portabilité – Futur d’Android
Et si Android n’était pas seulement
conçu pour les smartphone?
Android sur un NetBook
12. Intégration des applications Google
Barre de recherche « Google Search »
Gmail
Google Talk (IM)
Navigateur Web
Gmaps
Google StreetView
13. Exemples d’applications : Android Market
Géolocalisation
Orientation
Tourisme
Géolocalisation
Travail Voisinage
Google Maps
Voyage
Achats
Covoiturage
14. Points d’accès d’Android
Point de vue constructeur Point de vue utilisateur
Système fonctionnel,
Système Linux + Java
intuitif, évolutif
Point de vue bidouilleur Point de vue développeur
Application développées
Projet Open Source
en syntaxe Java
C++ / Java
SDK complet fourni
15. Architecture
APPLICATIONS
Home Contacts Phone Browser …
APPLICATION FRAMEWORK
Activity Manager Window Manager Content Providers View System
Package Telephony Resource Location Notification
Manager Manager Manager Manager Manager
JNI ANDROID RUNTIME
LIBRARIES
Core Libraries
Surface Manager Media Framework SQL Lite
Dalvik Virtual Machine
OpenGL Audio Manager WebKit
SGL SSL Libc
LINUX KERNEL
Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver
Keypad Driver WiFi Driver Audio Driver Power Management
16. Noyau d’Android
Architecture ARM
Basé sur Linux 2.6.24
Système de fichiers supporté : FAT32
Support de TCP/IP, UDP,…
HARDWARE ABSTRACTION LAYER
Graphics Audio Camera Bluetooth GPS WiFi …
LINUX KERNEL
Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver
Keypad Driver WiFi Driver Audio Driver Power Management
17. 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
HARDWARE ABSTRACTION LAYER
Graphics Audio Camera Bluetooth GPS WiFi …
LINUX KERNEL
Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver
Keypad Driver WiFi Driver Audio Driver Power Management
18. Librairies
LIBRARIES
Surface Manager Media Framework SQL Lite
OpenGL Audio Manager WebKit
SGL SSL Libc
LINUX KERNEL
Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver
Keypad Driver WiFi Driver Audio Driver Power Management
21. Machine Virtuelle Dalvik
ANDROID RUNTIME
LIBRARIES
Core Libraries
Surface Manager Media Framework SQL Lite
Dalvik Virtual Machine
OpenGL Audio Manager WebKit
SGL SSL Libc
LINUX KERNEL
Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver
Keypad Driver WiFi Driver Audio Driver Power Management
22. Machine Virtuelle Dalvik
Nouvelle instance pour chaque processus :
Applications indépendantes
Exécute des fichiers .dex (Dalvik Executable)
Dalvik core class library fournit une base de
développement proche de java SE, adapté
au mobile
23. Framework & fondations des applications
APPLICATION FRAMEWORK
Activity Manager Window Manager Content Providers View System
Package Telephony Resource Location Notification
Manager Manager Manager Manager Manager
JNI ANDROID RUNTIME
LIBRARIES
Core Libraries
Surface Manager Media Framework SQL Lite
Dalvik Virtual Machine
OpenGL Audio Manager WebKit
SGL SSL Libc
LINUX KERNEL
Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver
Keypad Driver WiFi Driver Audio Driver Power Management
24. Intents
Intent :
Requête; Description d’une action à effectuer
Fait le lien entre différentes applications
Décrit par :
Une action (VIEW, EDIT, MAIN,…)
La donnée à traiter (sous forme d’URI)
Types d’Intent :
Explicite (référence exacte)
Implicite (description)
26. Intent Filter
Objectif : Description du handler
Publication d’IntentFilters par les activités
IntentFilter décrivent les capacités de l’application.
<intent-filter>
<action android:value=quot;android.intent.action.VIEWquot; />
<action android:value=quot;android.intent.action.EDITquot; />
<action android:value=quot;android.intent.action.PICKquot; />
<category android:value=quot;android.intent.category.DEFAULTquot; />
<type
android:value=quot;vnd.android.cursor.dir/vnd.google.contactquot; />
</intent-filter>
27. Les URIs - Utilisation
Intent Exemples d’URI:
content: //contacts/ people/ 125
EDIT_ACTION
Ouvre l’application de géo-localisation à
geo: 25,32
VIEW_ACTION
la position donnée (latitude, longitude).
tel: 123 Appelle le numéro 123
CALL_ACTION
google.streetview: cbll=25,32 &cbp=1,yaw,,pitch,zoom
VIEW_ACTION
void startActivity(Intent intent) ;
void sendBroadcast(Intent intent)
boolean bindService(Intent service, int flags)
ComponentName startService(Intent service)
28. Notification Manager
Applications peuvent s’exécuter simultanément
Barre de notifications
Notifications d’événements du background
Mise en place facilité par le Notification
Manager
Différentes formes de notifications :
- LED
- Son
- Vibreur
- Barre de notification (icône)
30. Content Provider
SYSTEM APK
APK
service Activity service
Activity Activity
Data
XML
SQLite
Remote
data
31. Content Provider
APK
APK SYSTEM
service Activity service
Activity Activity
ContentProvider
Data
XML
SQLite
Remote
data
32. Les URIs
Intent
Activity
Receiver
Content
Exemples d’URI d’un content provider: Service
Provider
content: //contacts/ people/ 125
content: //com.maCompanie.monApp/ users/ 53
A Préfixe d’accès aux données, type d’URI
B Identifiant ou type du content provider à consulter
C 0 ou plusieurs segments, permettent de déterminer le type de données
D Enregistrement spécifique éventuellement demandé (identifiant, référence)
<provider class=quot;.NotePadProviderquot;android:authorities=quot;com.google.provider.NotePadquot; />
34. Activity
Intent
Objet qui possède un cycle de vie Activity
Receiver
Content
Service
Provider
Code qui réalise un traitement
Point d’entrée d’une application
Généralement, une Activity affiche une UI
<activity class=quot;.NoteEditorquot; android:label=quot;@string/title_notequot;>
<intent-filter android:label=quot;@string/resolve_editquot;>
<action android:value=quot;android.intent.action.VIEWquot; />
<action android:value=quot;android.intent.action.EDITquot; />
<category android:value=quot;android.intent.category.DEFAULTquot; />
<type android:value=quot;vnd.android.cursor.item/vnd.google.notequot; />
</intent-filter>
</activity>
35. Broadcast receiver
Broadcast
Activity
Receiver
Broadcast receiver permet de réagir à des Content
Service
évènements extérieurs à l’application Provider
Permet de réveiller une application
Un Intent peut être boadcasté; on peut utiliser un
broadcast receiver pour gérer ce type d’evt
Permet également de réagir à des notification du
système (évènements extérieurs/matériels).
<receiver android:name=quot;.app.OneShotAlarmquot; android:process=quot;:remotequot; />
36. Service
Intent
Activity
Receiver
Content
Service
Provider
Composante sans GUI
Activité de longue durée
Service interne : Context.startService()
Service externe : Context.bindService()
Communication via une interface
Ex Media Player : pause, lecture, stop, etc
37. Service : AndroidManifest
Intent
Activity
Receiver
Content
Service
Provider
<service android:name=quot;.app.RemoteServicequot; android:process=quot;:remotequot;>
<intent-filter>
<!-- These are the interfaces supported by the service, which
you can bind to. -->
<action android:name=quot;com.example.android.apis.app.IRemoteServicequot; />
<!-- This is an action code you can use to select the service
without explicitly supplying the implementation class. -->
<action android:name=quot;com.example.android.apis.app.REMOTE_SERVICEquot; />
</intent-filter>
</service>
39. Cycle de vie d’une Activité
Intent
Activity
Allocation des ressources
Receiver
OnCreate()
Content
Service
Provider
Affichage à l’écran
OnStart()
Passage au premier plan
OnResume()
Running
Passage en arrière plan
OnPause()
Paused
Arrêt de l’exécution
OnStop()
Stopped
OnDestroy() Libération des ressources
Killed
40. Cycle de vie d’une Activité
Retour à
New Activity l’application
1. OnCreate()
2. OnStart()
3. OnResume()
Application
Running
Killed
(Foreground)
OnFreeze()
OnResume()
OnPause()
3. OnResume() Besoin de
Paused
2. OnStart() mémoire
(Background)
1. OnRestart()
Application
OnStop()
plus visible
Stopped
(Plus visible)
L’utilisateur
OnDestroy()
quitte
Destroyed
41. Hiérarchie des processus
Hiérarchie des processus
Foreground Process Activité
Visible Process Activité en arrière plan
Importance
Processus des composants
Service Process « Service » disponibles en arrière plan
Background Process Processus en arrière plan, non visible.
Empty Process Cache pour les processus
42. Les applications
APPLICATIONS
Home Contacts Phone Browser …
APPLICATION FRAMEWORK
Activity Manager Window Manager Content Providers View System
Package Telephony Resource Location Notification
Manager Manager Manager Manager Manager
JNI ANDROID RUNTIME
LIBRARIES
Core Libraries
Surface Manager Media Framework SQL Lite
Dalvik Virtual Machine
OpenGL Audio Manager WebKit
SGL SSL Libc
LINUX KERNEL
Display Driver Camera Driver Flash Memory Driver Binder (IPC) Driver
Keypad Driver WiFi Driver Audio Driver Power Management
43. Développement en Java : Méthode classique
package com.android.hello; HelloAndroid.java
import android.app.Activity;
import android.os.Bundle;
JAVA
import android.widget.TextView;
(uniquement)
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);
1 champ de texte
tv.setText(quot;Hello, Androidquot;);
setContentView(tv);
}
}
44. Séparation Présentation / Métier
package com.android.hello; HelloAndroid.java
JAVA
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
métier
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);
}
}
XML
<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<TextView
xmlns:android=quot;http://schemas.android.com/apk/res/androidquot;
vues
android:layout_width=quot;fill_parentquot;
android:layout_height=quot;fill_parentquot;
android:text=quot;@string/helloquot;/> main.xml
45. Interfaçage des ressources
Génération
automatique
Description du layout package com.android.hello; R.java
public final class R {
icon.png
Image public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
Description main.xml public static final class layout {
du layout public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
Étiquettes strings.xml public static final int hello=0x7f040000;
Texte }
}