0% ont trouvé ce document utile (0 vote)
173 vues99 pages

01 - Introduction À Android

Ce document introduit le système d'exploitation Android. Il présente brièvement l'historique d'Android depuis sa création jusqu'aux versions les plus récentes. Le document décrit également les différentes versions d'Android ainsi que les nouvelles fonctionnalités apportées à chaque mise à jour majeure.

Transféré par

Michael LAGUERRE
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
173 vues99 pages

01 - Introduction À Android

Ce document introduit le système d'exploitation Android. Il présente brièvement l'historique d'Android depuis sa création jusqu'aux versions les plus récentes. Le document décrit également les différentes versions d'Android ainsi que les nouvelles fonctionnalités apportées à chaque mise à jour majeure.

Transféré par

Michael LAGUERRE
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd

Introduction à Android

SI5 - IHM / Techniques d’interactions / 2014-2015


Polytech Nice-Sophia / Michael LAGUERRE
Présentation

• Dans le mobile depuis 7 ans


• Android, iOS, WindowsPhone, J2ME, WindowsMobile

• J2ME-NFC chez ST-Ericsson - 2008


• Ingénieur mobile et IHM au Laboratoire I3S - 2008/2010
• Ingénieur R&D mobile et responsable développement Android
chez Playadz - 2011/2013
• Ingénieur R&D mobile et responsable mobile chez Ausy - 2014

[email protected]

2
Ausy - pôle mobilité

• Issu du rachat de Playadz, société fondée en 2007 par des


anciens de l’ESINSA et de l’EDHEC

• Spécialisée dans le développement d’applications multi-canal


(mobile, borne tactile, web)

• Plus d’une 60aine d’applications disponibles Android/iOS

• 8 personnes + 1 apprenti, basés sur Sophia-Antipolis

3
Ausy - pôle mobilité

• Nos références
• Conseils généraux 06 et 64
• Ville de Cannes
• Ports de la Côte d’Azur
• Aéroports de Paris
• Métro
• BVLGARI
• Schneider Electric
• ...

4
Un peu d’histoire

5
Le rêve de tous les enfants

• 1.0 - Alpha (fin 2007)


• 1.1 - Beta
• 1.2 - Apple Pie
• 1.3 - Banana Bread
• 1.5 - Cupcake (avril 2009)
• 1.6 - Donut (septembre 2009)
• 2.1 - Eclair (janvier 2010)
• 2.2 - Froyo (mai 2010)
• 2.3 - Gingerbread (décembre 2010)
• 3.X - Honeycomb (janvier 2011)
• 4.0 - Ice Cream Sandwich (octobre 2011)
• 4.1 - Jelly Bean (juillet 2012)
• 4.4 - KitKat (octobre 2013)
6
Un système innovant

7
Android 1.5 (Cupcake)
La première version, introduction des widgets

Avril 2009 8
Android 1.6 (Donut)
Parcourir le web, Google Maps

Septembre 2009 9
Android 2.0 (Eclair)
Homescreen personnalisé, dossiers

Janvier 2010 10
10
Android 2.2 (FroYo)
Contrôle vocal, notifications push

Mai 2010 11
11
Android 2.3 (Gingerbread)
Une version taillée pour le jeu : appuyez, pivotez, inclinez !

Décembre 2010 12
12
Android 3.0 (Honeycomb)
La version dédiée aux tablettes

Janvier 2011 13
13
Android 4.0 (Ice Cream Sandwich)
Design holo

Octobre 2011 14
14
Android 4.1 (Jelly Bean)
Un Android plus rapide, et plus intelligent
avec Google Now

Juillet 2012 15
15
Android 4.4 (Kitkat)
Réduction empreinte mémoire, Google Experience

Octobre 2013 16
16
2014 : Un monde multi-écrans

17
Android Wear

• Montres rondes ou carrées

• Version light d’Android 4.4(W)

• Commandé par voix et touch

• Affichage de notifications

• Commandes déportées (ex musique)

18
Android TV

• 3ème tentative dans le domaine de la télévision


• GoogleTV
• Chromecast

• Consommation de médias

• OS intégré dans la télévision ou set-top box

• Android L

• Commandé par voix, manette, téléphone, tablette

19
Android Auto

• Intégration avec l’ordinateur de bord de la


voiture

• Téléphone comme cerveau

• Données capteurs de la voiture (vitesse, gps …)

• Centre multimédia

• Navigation par Google Maps

• Partenariat avec les constructeurs

• Interface adaptée
• Gros boutons
• Lisible

20
Pourquoi choisir
Android ?
• Une multitude d’OS mobiles
• Les forces
• Les faiblesses
• Le problème de la fragmentation

21
Question

Sous quel OS tourne votre téléphone ?

22
Une multitude d’OS mobiles

23
Parts de marché des OS mobiles (smartphones) dans le monde

Android iOS Windows Phone Blackberry OS Autres Windows Phone


100 iOS 2 %
12 %
80

60

40

20

Android
0 85 %
2011Q2 2012Q2 2013Q2 2014Q2

24
Source : idc.com
MOBILE USA UK GERMANY FRANCE SPAIN

OPERATING SYSTEM
MARKET SHARE
JANUARY 2014

Apple iOS 52% Apple iOS 42% Android 63% Apple iOS 48% Android 72%
Android 39% Android 29% Apple iOS 32% Android 44% Apple iOS 24%
BlackBerry 5% BlackBerry 17% Windows 2% Windows 4% Windows 2%
Windows 2% Nokia 5% Other 3% Other 4% Other 2%
Other 2% Other 7%

BRAZIL RUSSIA INDIA CHINA AUSTRALIA

WORLDWIDE MARKET SHARE SINCE 2011


Android Apple iOS BlackBerry Nokia
Samsung Windows Other
50%

Android 60% Android 52% Nokia 36% Android 63% Apple iOS 64%
Apple iOS 14% Apple iOS 28% Android 33% Apple iOS 21% Android 33%
40%
Nokia 11% Nokia 10% Samsung 14% Nokia 4% Windows 2%
Windows 4% Windows 4% Other 17% Other 12% Other 1%
Other 11% Other 6%
30%

20% MEXICO INDONESIA NIGERIA TURKEY JAPAN

10%

0%
2011 2012 2013 2014

Data Source: http://gs.statcounter.com/


Published Under a Creative Commons Attribution 3.0 Unported License Android 59% Android 45% Nokia 51% Android 68% Apple iOS 61%
You are free to copy, distribute and transmit the work and to adapt the work
providing is it attributed to www.icrossing.co.uk Apple iOS 21% Nokia 33% Android 18% Apple iOS 18% Android 38%
http://connect.icrossing.co.uk/
Nokia 7% BlackBerry 5% Samsung 2% Nokia 8% Other 1%
Windows 6% Apple iOS 3% BlackBerry 2% Windows 4%
Other 7% Other 14% Other 27% Other 2%
25
25
MOBILE USA UK GERMANY FRANCE SPAIN

OPERATING
GERMANY SYSTEM FRANCE SPAIN
MARKET SHARE
JANUARY 2014

Apple iOS 52% Apple iOS 42% Android 63% Apple iOS 48% Android 72%
Android 39% Android 29% Apple iOS 32% Android 44% Apple iOS 24%
BlackBerry 5% BlackBerry 17% Windows 2% Windows 4% Windows 2%
Windows 2% Nokia 5% Other 3% Other 4% Other 2%
Other 2% Other 7%

BRAZIL RUSSIA INDIA CHINA AUSTRALIA

WORLDWIDE MARKET SHARE SINCE 2011


Android Apple iOS BlackBerry Nokia
Samsung Windows Other
50%

Android 60% Android 52% Nokia 36% Android 63% Apple iOS 64%
Apple iOS 14% Apple iOS 28% Android 33% Apple iOS 21% Android 33%
40%
Nokia 11% Nokia 10% Samsung 14% Nokia 4% Windows 2%
Windows 4% Windows 4% Other 17% Other 12% Other 1%
Other 11% Other 6%
30%

MEXICO INDONESIA NIGERIA TURKEY JAPAN


42% Android 63% Apple iOS 48% Android
20%

29% Apple iOS 32% Android 44% Apple iOS


10%

17% Windows 2% Windows 4% Windows


0%
2011 2012 2013 2014

5% Other
Data Source: http://gs.statcounter.com/
3% Other 4% Other
7%
Published Under a Creative Commons Attribution 3.0 Unported License Android 59% Android 45% Nokia 51% Android 68% Apple iOS 61%
You are free to copy, distribute and transmit the work and to adapt the work
providing is it attributed to www.icrossing.co.uk Apple iOS 21% Nokia 33% Android 18% Apple iOS 18% Android 38%
http://connect.icrossing.co.uk/
Nokia 7% BlackBerry 5% Samsung 2% Nokia 8% Other 1%
Windows 6% Apple iOS 3% BlackBerry 2% Windows 4%
Other 7% Other 14% Other 27% Other 2%
25
25
Les forces

• Système open-source (en partie) basé sur un


noyau Linux
• Accès plus en profondeur au matériel en
comparaison avec iOS pour le développeur
• Disponible sur une grande variété de devices
(téléphones, tablettes, montres, TV, voitures,
machines à laver ...)
• Peut être modifié pour s’adapter à un nouveau
matériel

26
TouchWiz
Les faiblesses

• Nature open-source

• Tous les constructeurs et intégrateurs


ajoutent leurs couches personnelles
(Sense, Motoblur, ...) Stock Android

• Très grande inertie dans les mises à jour


(téléphones encore en 2.3 mi 2014) Sense

• Hétérogénéité des plateformes

27 MotoBlur
Le problème de la fragmentation

• Beaucoup de matériels à supporter (~5000 modèles)

• Difficultés de prise en compte de toutes les


combinaisons hardware / software

• Fragmentation des OS (7 versions utilisées en parallèle à


l’heure actuelle)
Chiffres au 9 septembre 2014
• Comportements imprévisibles de certains terminaux dus
aux modifications logicielles des constructeurs

28
Le cycle de vie
d’une application
• L’idée
• La conception
• Le design et l’ergonomie
• Le développement
• Les tests
• La publication

29
L’idée

• Innovante

• Combler un vide

• Répondre à un besoin

• Créer de nouveaux usages

Règle d’or du développement mobile


1 application = 1 tâche
30
La conception

• Découpage de l’application en fonctionnalités

• Raffiner en tâches

• Chaque tâche devient un (ensemble d’) écran(s)

• Mise en place du screenflow

• Réflexion sur l’architecture logicielle, l’utilisation


des données, du matériel, des capteurs …

31
Le design et l’ergonomie

• Sans doute la partie la plus importante

• Souvent la plus négligée

• Une application au design bâclé et à l’ergonomie


imparfaite est vite rejetée par l’utilisateur

• Se mettre à la place de l’utilisateur

32
Le développement

• Compte développeur : 25$


!

• Langages :
• JAVA pour le code
• XML pour l’interface .java .xml
!

• Disponible sur Windows, MacOS, Linux


!

• IDE : Android Studio (Eclipse, plus supporté)

.APK

33
Les tests

• Ne pas les négliger

• Une application qui plante sera vite supprimée et remplacée

• Tests en JUnit

• Frameworks de test (ex: Robotium)

• Monkey testing (test aléatoire d’inputs utilisateur)

• Ne pas uniquement se reposer sur le Monkey testing

34
La publication

• Moyens de distribution
• Play Store
• 70% pour les développeurs
• 30% pour Google
• Stores alternatifs (Amazon ...) .APK
• Distribution direct sur site web

35
Play Store

• 22 octobre 2008 / Lancement de l’Android


Market (50 apps)

• 1er trimestre 2009 / Applications payantes

• 14 juillet 2010 / 1 milliard de téléchargements

• 2 Février 2011 / Android Webstore

• 12 juillet 2011 / Nouveau market pour 2.2+


(400 000 apps)

36
Des applications

• En octobre 2012
• 675 000+ applications
• 25 milliards de téléchargements
• 1,3 millions activations/jour
!

• En juillet 2013
• 1 million d’applications
• 50 milliards de téléchargements
• 1 milliards d’activations

37
Le but de tout développeur ...

38
Le but de tout développeur ...

38
Un marché difficile

• Au 1er Juillet 2013


• 1 millions d’applications
• 50 milliards de téléchargements

• Applications du Top 50 : 61% du temps passé sur Android

-> difficulté à sortir du lot

39
Développer pour
Android

40
Eclipse vs Android Studio

• Eclipse
• Utilisé depuis les débuts d’Android
• Plugin ADT (Android Development Toolkit)
• Compilation : ANT
!

• Android Studio
• Introduit à la Google I/O 2013
• Encore en Developer Preview
• Basé sur la dernière version d’IntelliJ
• Compilation : Gradle

41
Eclipse

42
Eclipse

42
Android Studio

43
Android SDK

Hierarchy
Viewer
LogCat
Emulateur

ADT draw9patch
44
Android SDK

• Contient :
• ADT (intégré dans Android Studio) / Librairies nécessaires au développement d’applications Android
• Emulateur Android / Création de devices virtuels -AVD- de différentes configurations hard/soft
• Hierarchy Viewer / Visualisation de l’arborescence d’un écran
• LogCat / Console de debug
• draw9patch / Création de ressources graphiques extensibles

45
Emulateur Android

46
Emulateur Android

46
Emulateur Android - Genymotion

10x plus rapide


que l’émulateur Android
47
Emulateur Android - Genymotion

Pas de Google Play Services :(

10x plus rapide


que l’émulateur Android
47
HierarchyViewer

48
LogCat

49
draw9patch

50
Anatomie d’un
projet Android

51
Anatomie d’un projet Android

Les fichiers générés


Les tests
Les librairies
JARs

Le code source java


Les ressources
- images
- textes
- couleurs
- layouts

La configuration de l’application

La configuration du projet
Les librairies
externes
52
Le fichier Manifest.xml

• Configuration globale de l’application


!
1 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
! 2 package="com.example.android"
3 android:versionCode="1"
4 android:versionName="1.0">
! 5
6 <uses-sdk android:minSdkVersion="10" />
7
8 <application android:icon="@drawable/ic_launcher">
! 9
10 ...
11
! 12 </application>
13 </manifest>
!
!

• Gère les permissions de l’application (accès à internet, à l’api de téléphonie ...)


!
!
1 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
2 <uses-permission android:name="android.permission.INTERNET" />
!

53
Le fichier Manifest.xml

• Configuration globale de l’application Migrés dans build.gradle


!
1 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
! 2 package="com.example.android"
3 android:versionCode="1"
4 android:versionName="1.0">
! 5
6 <uses-sdk android:minSdkVersion="10" />
7
8 <application android:icon="@drawable/ic_launcher">
! 9
10 ...
11
! 12 </application>
13 </manifest>
!
!

• Gère les permissions de l’application (accès à internet, à l’api de téléphonie ...)


!
!
1 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
2 <uses-permission android:name="android.permission.INTERNET" />
!

53
Le fichier Manifest.xml

• Gère l’accès au matériel (hardware requis)


!
! 1 <uses-feature android:name="android.hardware.bluetooth" />
2 <uses-feature android:name="android.hardware.camera" />

• Définit les composants de l’application ainsi que leurs propriétés (Activities,


Services ...)
!
1 <activity android:name=".Activity1" android:label="@string/app_name">
2 <intent-filter>
3 <action android:name="android.intent.action.MAIN" />
4 <category android:name="android.intent.category.LAUNCHER" />
5 </intent-filter>
6 </activity>

54
Le fichier build.gradle

• Paramètre l’application
!
1 apply plugin: 'com.android.application'
2
3 android {
4 compileSdkVersion 20
5 buildToolsVersion "20.0.0"
6
7 defaultConfig {
8 applicationId "com.michael_laguerre.daftmachine"
9 minSdkVersion 14
10 targetSdkVersion 20
11 versionCode 1
12 versionName "1.0"
13 }
14 buildTypes {
15 release {
16 runProguard false
17 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 }
19 }
20 }
21
22 dependencies {
23 compile fileTree(dir: 'libs', include: ['*.jar'])
24 compile 'com.android.support:support-v13:20.0.0'
25 }
55
Le fichier build.gradle

• Paramètre l’application Utilisation du plugin Android

!
1 apply plugin: 'com.android.application'
2
3 android {
4 compileSdkVersion 20 Configuration de l’application
5 buildToolsVersion "20.0.0"
6
7 defaultConfig {
8 applicationId "com.michael_laguerre.daftmachine"
9 minSdkVersion 14
10 targetSdkVersion 20
11 versionCode 1
12 versionName "1.0" Configuration des builds
13 }
14 buildTypes {
15 release {
16 runProguard false
17 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 }
19 }
20
21
} Dépendances externes
22 dependencies {
23 compile fileTree(dir: 'libs', include: ['*.jar'])
24 compile 'com.android.support:support-v13:20.0.0'
25 }
55
Gestion des ressources graphiques

• Dossier drawable-XXXX : images


• XXHDPI (ultra haute densité)
• XHDPI (très haute densité)
• HDPI (haute densité)
• MDPI (moyenne densité)
• LDPI (basse densité)

• Toujours essayer d’avoir les ressources dans toutes


les densités
xhdpi
• meilleurs rendus
• scaling consommateurs de ressources hdpi
(risque de OutOfMemoryException)
mdpi
!
http://developer.android.com/guide/practices/ ldpi
screens_support.html
12 8 6 4 3 56
Anatomie d’une
application
• Les activities
• Les services
• Les broadcast receivers
• Les contents providers
• Les intents

57
Anatomie d’une application Android

Activity Service
Correspond à un écran Processus de fond

ContentProvider BroadcastReceiver
Accès aux données Intercepte les évènements

Intents
58
Activity

• L’équivalent d’une page pour un site web

• Une application est composée de plusieurs activities

• Associée à une vue (généralement en xml)

http://developer.android.com/guide/components/activities.html

59
Activity : cycle de vie

• Cycle de vie global


• onCreate() -> onDestroy()
!

• Cycle de vie visible


• onStart() -> onStop()
• Affichée à l’écran mais peut ne pas être utilisable
(en second plan)
!

• Cycle de vie en premier plan


• onResume() -> onPause()

60 60
Activity

• A déclarer absolument dans le fichier Manifest


!

!
1 <?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="com.example.android"
4 android:versionCode="1"
5 android:versionName="1.0">
6
7 <uses-sdk android:minSdkVersion="10" />
8
9 <application android:icon="@drawable/icon" android:label="@string/app_name">
10
11 <activity android:name=".MyActivity" android:label="@string/app_name">
12
13 <intent-filter>
14 <action android:name="android.intent.action.MAIN" />
15 <category android:name="android.intent.category.LAUNCHER" />
16 </intent-filter>
17
18 </activity>
19
20 <activity android:name=".MySecondActivity" android:label="@string/app_name" />
21
22 </application>
23 </manifest>
!

61
Activity

• Méthode à implémenter absolument : onCreate();

!
1 package com.example.android;
2
3 import android.app.Activity;
4 import android.os.Bundle;
5
6 public class MyActivity extends Activity {
7 /** Called when the activity is first created. */
8 @Override
9 public void onCreate(Bundle savedInstanceState) {
10 super.onCreate(savedInstanceState);
11 setContentView(R.layout.main);
12 }
13 }

62
Services

• Processus s'exécutant en background


• Ne possède pas d’interface graphique
• Utilisé en général pour les traitements lourds
• Téléchargement de données
• Calcul intensif
• Lecture de l’audio
• Accès réseaux ...
!

http://developer.android.com/guide/components/services.html

63
Broadcast Receivers

• Intercepteur d’évènements (écoute d’un type d’Intent)

• Effectue une action à la réception d’un Intent donné

• Lancer une application

• Mettre à jour les données d’une certaine application

• Traiter des informations et les stocker en base

• ...

• Exemple : utilisation dans le système de push android

64
Broadcast Receivers

Système

BR
Application

Applications BD

Service 65
Broadcast Receivers

!
1 <?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="com.example.android"
4 android:versionCode="1"
5 android:versionName="1.0">
6
7 <uses-sdk android:minSdkVersion="9" />
8 <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
9
10 <application android:icon="@drawable/icon" android:label="@string/app_name">
11
12 <receiver android:name=".MyPhoneReceiver">
13 <intent-filter>
14 <action android:name="android.intent.action.PHONE_STATE"/>
15 </intent-filter>
16 </receiver>
17
18 </application>
19
20 </manifest>
!

Déclaration d’un BroadcastReceiver dans le Manifest


66
Broadcast Receivers

!
1 package com.example.android;
2
3 import android.content.BroadcastReceiver;
4 import android.content.Context;
5 import android.content.Intent;
6 import android.os.Bundle;
7 import android.telephony.TelephonyManager;
8 import android.util.Log;
9
10 public class MyPhoneReceiver extends BroadcastReceiver {
11
12 @Override
13 public void onReceive(Context context, Intent intent) {
14 Bundle extras = intent.getExtras();
15 if (extras != null) {
16 String state = extras.getString(TelephonyManager.EXTRA_STATE);
17 Log.w("DEBUG", state);
18 if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
19 String phoneNumber = extras.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
20 Log.w("DEBUG", phoneNumber);
21 }
22 }
23 }
24 }

Déclaration d’un BroadcastReceiver en JAVA


67
Content Providers

• Surcouche à une base de données (SQLite, fichiers ...)


• Permet de partager les données avec d’autres applications (exemple : récupération du carnet d’adresse à
partir d’une autre application)
• Données accessibles grâce à une URI
• Sources de données accessibles grâce à des Content Providers
• Contacts
• Calendriers
• Media
• ...
http://developer.android.com/guide/topics/providers/content-providers.html

68
Intents

• Messages envoyés au sein du système

• Système de communication privilégié inter- Ac Sv


composant

• Communication entre toutes les entités et


applications du système

• Peut contenir des données

• Réutilisation de partie d’applications existantes CP BR


au sein de sa propre application

Intents
69
Intents

• 2 types d’Intent :

• Explicite : spécifie la classe à appeler

!
!
! 1 Intent explicit = new Intent(this, CalledClass.class);
! 2 explicit.putExtra("key1", "value1");
! 3 explicit.putExtra("key2", "value2");
! 4 startActivity(explicit);
!

• Implicite : spécifie une action à effectuer

!
1 Intent implicit = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
2 startActivity(implicit);
!

70
Intents

• Récupération des données contenues dans l’Intent envoyé :


• Activity1.java

! !
!
1 Intent explicit = new Intent(this, Activity2.class);
2 explicit.putExtra("key1", "value1String");
! 3 explicit.putExtra("key2", "value2Int");
4 startActivity(explicit);
!
!

• Activity2.java
!
!
1 Intent callingIntent = getIntent();
2 String value1 = callingIntent.getStringExtra("key1");
3 int value2 = callingIntent.getIntExtra("key2", -1);
!
!

71
Intents - Intent filters

• Enregistrement pour répondre à un Intent implicite


• Permet de rendre disponible publiquement une fonctionnalité d’une application
!
!
!
!
http://developer.android.com/guide/components/intents-filters.html
1 <?xml version="1.0" encoding="utf-8"?>
2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="com.example.android"
4 android:versionCode="1"
5 android:versionName="1.0">
6
7 <uses-sdk android:minSdkVersion="9" />
8 <uses-permission android:name="android.permission.INTERNET"/>
9
10 <application android:icon="@drawable/icon" android:label="@string/app_name">
11
12 <activity android:name=".BrowserActivity" android:label="@string/app_name">
13
14 <intent-filter>
15 <action android:name="android.intent.action.VIEW" />
16 <category android:name="android.intent.category.DEFAULT" />
17 <data android:scheme="http" />
18 </intent-filter>
19
20 </activity>
21
22 </application>
23
24 </manifest>

72
Une application mobile, c’est :

Réseau

Data Capteurs

Interface
graphique Services OS

73
Google Play Services

• Ensemble d’API Google « extraites » d’Android • Google Maps API


• Geofencing
• APK installé sur 93% des terminaux -> réduction des effets de • Fused Location Provider
la fragmentation • Reconnaissance d’activité
• Google Play Games API
• Mise-à-jour toutes les 6 semaines • Google+ API
• Google Drive API
• Google Cast API
• Portage de nouvelles API sur les anciennes versions d’Android
• Google Mobile Ads
• Google Wallet
• Google Cloud Messaging
• …
• … et plein d’autres à venir

74
Un peu d’interface
graphique
Layouts
Widgets
Vues spécialisées
Dialogues

75
Editeur d’interfaces

• 2 modes d’édition
• placement graphique (drag’n’drop)
• écriture d’XML

• Produit des fichiers XML pouvant être


associés à une Activity

• Permet de spécifier les caractéristiques du


téléphone

• Langue
• Orientation
• Type de téléphone
• Taille d’écran …

76
Widgets

Widgets formulaire Date/Time picker Spinner ViewPager

77
Layouts LinearLayout RelativeLayout

• Containeurs permettant
l’alignement de composants
• Responsive design
!

• http://developer.android.com/
guide/topics/ui/declaring-
layout.html
ListView GridView

78
Vues spécialisées

MapView WebView ScrollView

79
Dialogues

• http://developer.android.com/design/building-blocks/dialogs.html

AlertDialog ProgressDialog CustomDialog


80
Material Design

82
Material Design

• Papier et encre

• Ombres subtiles

• Animations

• Transitions qui ont du sens

• Couleurs vives

• Espacement

• Typographie

83
Connectivité
Webservices

84
Webservices

• API natives HTTP Android trop lourdes à utiliser


• Préférez des librairies pour les requêtes standards
• Volley (Google)
• Unirest (Mashape)
• Ion (Koush)
• OkHTTP (Square)
!

• Fonctionnent sur le principe des callbacks


• Réponse asynchrone
• Téléchargement sur un autre thread
en background

85
Webservices | Ion

! !
1 public class IonActivity extends Activity {
! 2
3 @Override
4 protected void onCreate(Bundle savedInstanceState) {
!
5 super.onCreate(savedInstanceState);
6 setContentView(R.layout.activity_main);
! 7
8 String url = "https://www.example.com/webservice.json";
! 9
10 Ion.with(this, url).asJsonObject()
11 .setCallback(new FutureCallback<JsonObject>() {
! 12
13 @Override
! 14 public void onCompleted(Exception e, JsonObject result) {
15 // Récuperation de la réponse du webservice
16 }
! 17 });
18 }
! 19 }

! Appel d’un webservice avec Ion


!

• https://github.com/koush/ion
86
Conclusion
Une plateforme en pleine expansion
!
Un potentiel énorme
!
Une grande variété de matériel
!
Le plaisir de créer

87
Bibliographie

88
Inspiration
http://inspired-ui.com

89
Inspiration
http://www.pttrns.com

90
Inspiration
http://capptivate.co

91
Tips Android
Librairies utiles

• Retrofit : Appels réseau + transformation JSON <-> objets


http://square.github.io/retrofit/

• Picasso : Téléchargement des images en background


http://square.github.io/picasso/

• EventBus : Bus évènementiel de communication entre composants


https://github.com/greenrobot/EventBus

• GreenDao : ORM SQLite pour Android


http://greendao-orm.com/

• Android Asset Studio : Générateur de ressources Android


http://romannurik.github.io/AndroidAssetStudio/

92
Webographie

• http://developer.android.com

• http://developer.android.com/guide/index.html

• https://developers.google.com/live/

93

Vous aimerez peut-être aussi