1 / 53

Ouverture

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. Contexte. 3.

nevin
Download Presentation

Ouverture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction à Android by Jean Collas, Ghislain Deffrasne, Reda Sebbaniis licensed under a Creative Commons Attribution 2.0 France License. • Original at http://www.jean-collas.fr/android

  2. Ouverture Jean Collas, Réda Sebbani, Ghislain Deffrasnes

  3. Contexte 3 Téléphonie Mobile : Smart Phone Développement logiciel pour mobiles Contexte Chiffre d’affaire énorme Windows Mobile RIM 40 millions de smartphones / trimestre (2008) Symbian iPhone OS

  4. 5 Contexte Concurrentiel 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

  5. 6 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 fort d’Android 7 Point de vue constructeur Point de vue utilisateur Point de vue développeur Point de vue bidouilleur Système Linux + Java Système fonctionnel, intuitif, évolutif Application développées en syntaxe Java SDK complet fourni Projet Open Source C++ / Java Points forts d’Android

  7. Historique 8 Historique T-Mobile G1 Novembre 2008 Android 1.0 et SDK release 2 Android : Open Source Octobre 2008 Android 1.0 et SDK release 1 Septembre 2008 AndroidMarket Août 2008 Avril 2008 Développement d’Android Developer Challenge Open Handset Alliance Annonce d’Android SDK pour Android Novembre 2007 Start-up Android Août 2005

  8. 9 Open Handset Alliance • 47 compagnies Fabricants de semi-conducteurs • Consortium créé fin 2007 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 (HTC) 10 T-Mobile G1 • 1ertéléphone avec Android • De 180 à 400 $ • Wi-fi et Bluetooth • GPS • Accéléromètres • Caméra • Écran tactile

  10. De nouveaux mobiles 11 LG L’agora par Kogan http://www.businessmobile.fr/solutions-mobiles/guides-mobilite/0,39044672,39220692,00.htm

  11. Preuve de sa portabilité – Futur d’Android 13 Et si Android n’était pas seulement conçu pour les smartphone? Android sur un NetBook

  12. Intégration des applications Google 15 • Barre de recherche « Google Search » • Gmail • Google Talk (IM) • Navigateur Web • Gmaps • Google StreetView

  13. Exemples d’applications : Android Market 16 Géolocalisation Orientation Tourisme Géolocalisation Travail Voisinage Google Maps Voyage Achats Covoiturage

  14. Points d’accès d’Android 17 Point de vue constructeur Point de vue utilisateur Point de vue développeur Point de vue bidouilleur Système Linux + Java Système fonctionnel, intuitif, évolutif Application développées en syntaxe Java SDK complet fourni Projet Open Source C++ / Java

  15. Architecture 18 APPLICATIONS Home Contacts Phone Browser … APPLICATION FRAMEWORK Activity Manager Window Manager Content Providers View System Package Manager Telephony Manager Resource Manager Location Manager Notification Manager JNI ANDROID RUNTIME LIBRARIES Surface Manager Media Framework SQL Lite CoreLibraries OpenGL Audio Manager WebKit Dalvik Virtual Machine 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 19 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 20 • 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 21 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

  19. Surface Manager 22 Application 1 Surface Flinger Application 2 Écran (Frame Buffer)

  20. Audio Manager 23 Sonnerie d’appel Audio Flinger Oreillette Lecteur MP3 Écouteurs

  21. Machine Virtuelle Dalvik 24 ANDROID RUNTIME LIBRARIES Surface Manager Media Framework SQL Lite CoreLibraries OpenGL Audio Manager WebKit Dalvik Virtual Machine 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 25 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 & fondationsdes applications 26 APPLICATION FRAMEWORK Activity Manager Window Manager Content Providers View System Package Manager Telephony Manager Resource Manager Location Manager Notification Manager JNI ANDROID RUNTIME LIBRARIES Surface Manager Media Framework SQL Lite CoreLibraries OpenGL Audio Manager WebKit Dalvik Virtual Machine 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 27 • 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)

  25. Intents 28 Intent Resolver Intent 1 App.A Intent 2 App.B . . Publication Edit ContactContacts View Contact Contacts IntentFilter VIEW EDIT StartActivity(View Contact) 2 1 Echange 3 Messagerie Contacts

  26. 29 Intent Filter Objectif : Description du handler Publication d’IntentFilters par les activités IntentFilter décrivent les capacités de l’application. <intent-filter> <actionandroid:value="android.intent.action.VIEW"/> <actionandroid:value="android.intent.action.EDIT"/> <actionandroid:value="android.intent.action.PICK"/> <category android:value="android.intent.category.DEFAULT" /> <type android:value="vnd.android.cursor.dir/vnd.google.contact" /> </intent-filter>

  27. Les URIs - Utilisation 30 Intent Exemples d’URI: EDIT_ACTION Ouvre l’application de géo-localisation à la position donnée (latitude, longitude). VIEW_ACTION geo: tel: content: google.streetview: people/ 125 123 25,32 //contacts/ cbll=25,32 Appelle le numéro 123 CALL_ACTION VIEW_ACTION &cbp=1,yaw,,pitch,zoom void startActivity(Intent intent) ; void sendBroadcast(Intent intent)boolean bindService(Intent service, int flags) ComponentName startService(Intent service)

  28. Notification Manager 31 Applications peuvent s’exécuter simultanément Barre de notifications Notificationsd’é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)

  29. 32 Composants d’une application Activity Broadcast Receiver Service Content Provider

  30. ContentProvider 33 SYSTEM APK APK service Activity service Activity Activity Data SQLite XML Remote data

  31. ContentProvider 34 SYSTEM APK APK service Activity service Activity Activity ContentProvider Data SQLite XML Remote data

  32. Les URIs 35 Exemples d’URI d’un content provider: Activity IntentReceiver Service Content Provider content: content: people/ 125 users/ 53 //com.maCompanie.monApp/ //contacts/ 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) <providerclass=".NotePadProvider"android:authorities="com.google.provider.NotePad"/>

  33. ContentProvider 36 URI : content: people/ 125 //contacts/ Activity IntentReceiver Applications Content Providers Service Content Provider URI Browser Annuaire Settings ContentResolver • + delete() • + insert() • + notifyChange() • + query() • + update() Résultat Contacts Lecteur MP3 MediaStore.Images MediaStore.Audio

  34. 37 Objet qui possède un cycle de vie Code qui réalise un traitement Activity IntentReceiver Activity Point d’entrée d’une application Service Content Provider Généralement, uneActivityafficheune UI <activityclass=".NoteEditor"android:label="@string/title_note"> <intent-filterandroid:label="@string/resolve_edit"> <actionandroid:value="android.intent.action.VIEW"/> <actionandroid:value="android.intent.action.EDIT"/> <categoryandroid:value="android.intent.category.DEFAULT"/> <typeandroid:value="vnd.android.cursor.item/vnd.google.note"/> </intent-filter> </activity>

  35. Broadcast receiver 38 Broadcast receiver permet de réagir à des évènements extérieurs à l’application Activity BroadcastReceiver Service Permet de réveiller une application Content Provider . 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). <receiverandroid:name=".app.OneShotAlarm"android:process=":remote"/>

  36. 39 Activity IntentReceiver Composante sans GUI Activité de longue durée Service Service Content Provider Service interne : Context.startService() Service externe : Context.bindService() Communication via une interface Ex Media Player : pause, lecture, stop, etc

  37. Service : AndroidManifest 40 <serviceandroid:name=".app.RemoteService"android:process=":remote"> <intent-filter> <!-- These are the interfaces supported by the service, which you can bind to. --> <actionandroid: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. --> <actionandroid:name="com.example.android.apis.app.REMOTE_SERVICE"/> </intent-filter> </service> Activity IntentReceiver Service Content Provider

  38. AndroidManifest complet 41 <manifestxmlns:android="http://schemas.android.com/apk/res/android" package="com.android.notepad"> <applicationandroid:icon="@drawable/app_notes"android:label="@string/app_name"> <activityclass=".NotesList"android:label="@string/title_notes_list"> <intent-filter> <actionandroid:value="android.intent.action.MAIN"/> <categoryandroid:value="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <providerclass=".NotePadProvider"android:authorities="com.google.provider.NotePad"/>  <serviceandroid:name=".app.RemoteService"android:process=":remote"> <intent-filter> <actionandroid:name="com.example.android.apis.app.IRemoteService"/> </intent-filter> </service> <receiverandroid:name=".app.OneShotAlarm"android:process=":remote"/> </application> </manifest> Activity Activity IntentReceiver Service Content Provider Content Provider Service IntentReceiver

  39. Cycle de vie d’une Activité 42 OnCreate() Allocation des ressources Activity IntentReceiver OnStart() Affichage à l’écran Service Content Provider Running OnResume() Passage au premier plan Paused • 4 états : • active/running • paused • stopped • killed/shut down OnPause() Passage en arrière plan Stopped OnStop() Arrêt de l’exécution Killed OnDestroy() Libération des ressources

  40. Cycle de vie d’une Activité 43 Retour à l’application New Activity 1. OnCreate() 2. OnStart() 3. OnResume() Application Killed Running (Foreground) OnFreeze() OnPause() OnResume() Besoin de mémoire 3. OnResume() 2. OnStart() 1. OnRestart() Paused (Background) Application plus visible OnStop() Stopped (Plus visible) L’utilisateur quitte OnDestroy() Destroyed

  41. Hiérarchie des processus 44 Hiérarchie des processus ForegroundProcess Activité Importance Visible Process Activité en arrière plan Processus des composants « Service » disponibles en arrière plan Service Process Background Process Processus en arrière plan, non visible. EmptyProcess Cache pour les processus

  42. Les applications 45 APPLICATIONS Home Contacts Phone Browser … APPLICATION FRAMEWORK Activity Manager Window Manager Content Providers View System Package Manager Telephony Manager Resource Manager Location Manager Notification Manager JNI ANDROID RUNTIME LIBRARIES Surface Manager Media Framework SQL Lite CoreLibraries OpenGL Audio Manager WebKit Dalvik Virtual Machine 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 46 packagecom.android.hello; import android.app.Activity; importandroid.os.Bundle; importandroid.widget.TextView; publicclassHelloAndroidextends Activity { /**Calledwhentheactivityisfirstcreated.*/ @Override publicvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextViewtv = newTextView(this); tv.setText("Hello, Android"); setContentView(tv); } } HelloAndroid.java JAVA (uniquement) 1 champ de texte

  44. Séparation Présentation / Métier 47 packagecom.android.hello; import android.app.Activity; importandroid.os.Bundle; importandroid.widget.TextView; publicclassHelloAndroidextends Activity { /**Calledwhentheactivityisfirstcreated.*/ @Override publicvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } HelloAndroid.java JAVA métier <?xmlversion="1.0"encoding="utf-8"?> <TextViewxmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/hello"/> XML vues main.xml

  45. Interfaçage des ressources 48 Génération automatique Description du layout packagecom.android.hello; publicfinalclass R { publicstaticfinalclassattr { } publicstaticfinalclassdrawable { publicstaticfinalint icon=0x7f020000; } publicstaticfinalclass layout { publicstaticfinalint main=0x7f030000; } publicstaticfinalclass string { publicstaticfinalintapp_name=0x7f040001; publicstaticfinalint hello=0x7f040000; } } R.java icon.png Image main.xml Description du layout strings.xml Étiquettes Texte

  46. Compilation et Déploiement d’une Application 50 Byte-code (optimisé) Sources .dex .java .class .png .xml .apk /data/app/ Ressources + Manifest Application compilée

  47. HelloWorld 51

  48. Vidéos StreetView + Compass 52

  49. ? Vidéos StreetView + Compass 53

More Related