01 - Introduction À Android
01 - Introduction À Android
2
Ausy - pôle mobilité
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
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
• Affichage de notifications
18
Android TV
• Consommation de médias
• Android L
19
Android Auto
• Centre multimédia
• 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
22
Une multitude d’OS mobiles
23
Parts de marché des OS mobiles (smartphones) dans le monde
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%
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%
10%
0%
2011 2012 2013 2014
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%
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%
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
26
TouchWiz
Les faiblesses
• Nature open-source
27 MotoBlur
Le problème de la fragmentation
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
• Raffiner en tâches
31
Le design et l’ergonomie
32
Le développement
• Langages :
• JAVA pour le code
• XML pour l’interface .java .xml
!
.APK
33
Les tests
• Tests en JUnit
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
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
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
48
LogCat
49
draw9patch
50
Anatomie d’un
projet Android
51
Anatomie d’un projet Android
La configuration de l’application
La configuration du projet
Les librairies
externes
52
Le fichier Manifest.xml
53
Le fichier Manifest.xml
53
Le fichier Manifest.xml
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
!
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
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
http://developer.android.com/guide/components/activities.html
59
Activity : cycle de vie
60 60
Activity
!
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
!
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
http://developer.android.com/guide/components/services.html
63
Broadcast Receivers
• ...
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>
!
!
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 }
68
Intents
Intents
69
Intents
• 2 types d’Intent :
!
!
! 1 Intent explicit = new Intent(this, CalledClass.class);
! 2 explicit.putExtra("key1", "value1");
! 3 explicit.putExtra("key2", "value2");
! 4 startActivity(explicit);
!
!
1 Intent implicit = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
2 startActivity(implicit);
!
70
Intents
! !
!
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
72
Une application mobile, c’est :
Réseau
Data Capteurs
Interface
graphique Services OS
73
Google Play Services
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
• Langue
• Orientation
• Type de téléphone
• Taille d’écran …
76
Widgets
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
79
Dialogues
• http://developer.android.com/design/building-blocks/dialogs.html
82
Material Design
• Papier et encre
• Ombres subtiles
• Animations
• Couleurs vives
• Espacement
• Typographie
83
Connectivité
Webservices
84
Webservices
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 }
• 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
92
Webographie
• http://developer.android.com
• http://developer.android.com/guide/index.html
• https://developers.google.com/live/
93