Les versions

Comment coder en respectant les standards

Les logs ?

Qu’utiliser ?

Le guide : Log Sparingly indique :

  • System.out.println() (ou printf() pour le code natif) ne doit jamais être utilisé.

Utilisation Des Log.x

L’utilisation abusive des méthodes Log.x engendre un ralentissement du temps d’exécution de votre application. Également, elles ne doivent pas être présentes lors de la diffusion de votre programme sur le Google Play.

Android Logging Tutorial

Android advises that a deployed application should not contain logging code. The Android development tools provide the BuildConfig.DEBUG flag for this purpose.

Issue 27940: BuildConfig.DEBUG is "true" for exported application package

Sometimes BuildConfig.DEBUG is "true" after exporting application package if exported app references android library project and "Project->Build Automatically" is checked

Be Careful With BuildConfig.DEBUG

There are bugs in the build system that cause exported signed release builds to be built with BuildConfig.DEBUG set to true!

Android Essentials: Application Logging

Déboguer des applications Android

AndroidManifest.xml (les permissions)

  • Manifest.permission
    • ACCESS_COARSE_LOCATION Allows an app to access approximate location derived from network location sources such as cell towers and Wi-Fi.
    • ACCESS_FINE_LOCATION Allows an app to access precise location from location sources such as GPS, cell towers, and Wi-Fi.
    • ACCESS_NETWORK_STATE Allows applications to access information about networks
    • ACCESS_WIFI_STATE Allows applications to access information about Wi-Fi networks
    • CHANGE_NETWORK_STATE Allows applications to change network connectivity state
    • INTERNET Allows applications to open network sockets.

Connectivité Smartphone : connecté en 3G, 4G, ... ou en WIFI, ou pas connecté du tout ?

AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

AsyncTask : tâches asynchrones

  • AsyncTask : android.os.AsyncTask<Params, Progress, Result> : 3 generic types, called Params, Progress and Result, and 4 steps, called onPreExecute, doInBackground, onProgressUpdate and onPostExecute.
  • Les AsyncTask

WebView

Ne fonctionne pas

Android webview html compliance?

Le WebView ne supporte pas le "%", il faut le remplacer avec "%25". (Caractères spéciaux)

Et ? "#" en "%23"

XSLT

Ne semble pas aimer les caractères accentués et les commentaires du fichier .xsl

HTTP Upload File from Android

org.apache.commons.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is application/x-www-form-urlencoded

android take photo without store in gallery

RadioGroup et RadioButton

Comme l'indique Android RadioButton not able to set using setChecked(false) method, il est impossible de décocher un radio bouton, sans quoi vous ne pourrez plus le réactiver, il faudra dont passer par le conteneur RadioGroup.

/**
		 * It is not possible to uncheck a particular radio button. You can only set the other item to true.
		 * So to clear all the checked items, you should call the clearcheck() method on the RadioGroup.
		 * ((RadioGroup) findViewById(R.id.ID0)).clearCheck();
		 */

BroadcastReceiver LocalBroadcastManager

Signaler des changements (y compris de puis un service) avec les Broadcast et les intercepter avec les Receiver

Déploiement

A la recherche de compatibilité pour éviter :

  • application non compatible
  • application pour mobile (pas tablette)

Langues

Tarifs et disponibilité > Distribuer l'application dans les pays suivants

Activer toutes les langues pour éviter d'être bloqué par des téléphones upgradés avec une ROM externe au pays (ce qui est souvent le cas avec les tels rootés).

Mobile et tablette

Conseils d'optimisation

Optimisez votre application pour les tablettes.

Importez des captures d'écran pour tablette :

Importez au moins une capture d'écran pour les tablettes 7 et 10 pouces dans la fiche Google Play Store.

En optimisant votre application pour les tablettes, vous toucherez davantage de clients via une gamme d'appareils plus vaste. Les applications conçues pour les tablettes sont répertoriées dans la liste "Applications conçues pour les tablettes" sur le Play Store.

Utilisation de la boîte de dialogue "Disponibilité des appareils"

La boîte de dialogue "Disponibilité des appareils" est un nouvel outil puissant mis à la disposition de tous les développeurs. Elle est accessible à partir de la console développeur Google Play. L'outil de disponibilité des appareils fournit une liste dynamique des appareils compatibles en fonction des paramètres de votre fichier manifeste. Par exemple, si le manifeste du fichier .APK spécifie une grande taille d'écran, la console présente les appareils compatibles pouvant trouver votre application dans Google Play. Vous pouvez également utiliser la fonctionnalité de recherche dynamique pour afficher les appareils qui ne sont pas compatibles avec votre application. Il est possible d'effectuer une recherche en fonction du fabricant, du nom de conception (par exemple, "Passion"), ou du nom public réel de l'appareil (par exemple, "Nexus One") afin de voir si les paramètres de votre fichier manifeste ont filtré un appareil.

Compatibilité

Les résolutions drawable : ldpi mdpi hdpi xhdpi xxhdpi

Application pour connaitre la DPI de l'écran :

Samsung GT-S5830 (Galaxy Ace)
  • Width : 320
  • Height : 480
  • Density : 1
  • Density DPI : 160 (DENSITY_MEDIUM)
HTC Desire et HTC HD2
  • Width : 480
  • Height : 800
  • Density : 1.5
  • Density DPI : 240 (DENSITY_HIGH)
Samsung GT-I9505 (Galaxy Note II)
  • Width : 720
  • Height : 1280
  • Density : 2.0
  • Density DPI : 320 (DENSITY_XHIGH)
Samsung GT-I9505 (Galaxy S4)
  • Width : 1080
  • Height : 1920
  • Density : 3.0
  • Density DPI : 480 (Other density type)
Google Nexus 7
  • Width : 1200
  • Height : 1824
  • Density : 2.0
  • Density DPI : 320 (DENSITY_XHIGH)

Ressources sur "drawable"

android.util.DisplayMetrics
  • int 400 DENSITY_400 Intermediate density for screens that sit somewhere between DENSITY_XHIGH (320dpi) and DENSITY_XXHIGH (480 dpi).
  • int 160 DENSITY_DEFAULT The reference density used throughout the system.
  • int 240 DENSITY_HIGH Standard quantized DPI for high-density screens.
  • int 120 DENSITY_LOW Standard quantized DPI for low-density screens.
  • int 160 DENSITY_MEDIUM Standard quantized DPI for medium-density screens.
  • int 213 DENSITY_TV This is a secondary density, added for some common screen configurations.
  • int 320 DENSITY_XHIGH Standard quantized DPI for extra-high-density screens.
  • int 480 DENSITY_XXHIGH Standard quantized DPI for extra-extra-high-density screens.
  • int 640 DENSITY_XXXHIGH Standard quantized DPI for extra-extra-extra-high-density screens.
Providing Resources
  • Screen pixel density (dpi)
    • ldpi: Low-density screens; approximately 120dpi.
    • mdpi: Medium-density (on traditional HVGA) screens; approximately 160dpi.
    • hdpi: High-density screens; approximately 240dpi.
    • xhdpi: Extra high-density screens; approximately 320dpi. Added in API Level 8
    • nodpi: This can be used for bitmap resources that you do not want to be scaled to match the device density.
    • tvdpi: Screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a "primary" density group. It is mostly intended for televisions and most apps shouldn't need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate.
Supporting Multiple Screens
Dashboards : Screen Sizes and Densities
Iconography

Note: Android also supports low-density (LDPI) screens, but you normally don't need to create custom assets at this size because Android effectively down-scales your HDPI assets by 1/2 to match the expected size.

Android cheatsheet for graphic designers
Android: Screen Densities, Sizes, Configurations, and Icon Sizes
Android: Working with Images

Notice that the drawable-ldpi folder does not contain the image as many devices no longer need that low of resolution because screen sizes and density levels of devices have increase over the years. The Android system will scale down the image in the drawable-mdpi directory to fit screens that would use this resource. Also notice that the name of each image is identical in each of the folders.

A density-independent pixel (dp) uses a baseline measurement of 1px = 1dp at a screen density of 160dpi. This is the “normal” density of the Android system and image resources designed for this density should be stored in the drawable-mdpi directory.

  • Low Density (ldpi) : res/drawable-ldpi directory. A low-density screen has 120dpi.
  • Medium Density (mdpi) : res/drawable-mdpi directory. A medium-density screen has 160dpi.
  • High Density (hdpi) : res/drawable-hdpi directory. A high-density screen has 240dpi.
  • Extra High Density (xhdpi) : res/drawable-xhdpi directory. An extra high-density screen has 320dpi.
  • Extra Extra High Density (xxhdpi) : res/drawable-xxhdpi directory. An extra extra high-density screen has approximately 480dpi.

Les outils de génération, conversion d'images de logo, icones

glEsVersion="0x00020000"

Is there a way to check if Android device supports openGL ES 2.0?

Vous pouvez également exiger vouloir restreindre les périphériques qui ne prennent pas en charge 2.0 de votre application sur le marché en ajoutant la ligne suivante à votre manifeste :

<uses-feature android:glEsVersion="0x00020000" android:required="true" />
Android Maps API requires openGL es 2

Cela indique aux services extérieurs l'exigence. En particulier, il a pour effet d'empêcher Google Play Store d'afficher votre application sur des appareils qui ne prennent pas en charge OpenGL ES version 2.

Issue 4699: Bug: Crash on supported devices when OpenGL is set to android:required="false"

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapdemo/com.example.mapdemo.RawMapViewDemoActivity}: java.lang.RuntimeException: Google Maps Android API only supports OpenGL ES 2.0 andabove. Please add <uses-feature android:glEsVersion="0x00020000" android:required="true" /> into AndroidManifest.xml

OpenGL ES

Android supports several versions of the OpenGL ES API:

  • OpenGL ES 1.0 and 1.1 - This API specification is supported by Android 1.0 and higher.
  • OpenGL ES 2.0 - This API specification is supported by Android 2.2 (API level 8) and higher.
  • OpenGL ES 3.0 - This API specification is supported by Android 4.3 (API level 18) and higher.

OpenGL ES version requirements - If your application only supports OpenGL ES 2.0, you must declare that requirement by adding the following settings to your manifest as shown below.

<!-- Tell the system this app requires OpenGL ES 2.0. -->
<uses-feature android:glEsVersion="0x00020000" android:required="true" />

Adding this declaration causes Google Play to restrict your application from being installed on devices that do not support OpenGL ES 2.0. If your application is exclusively for devices that support OpenGL ES 3.0, you can also specify this in your manifest:

<!-- Tell the system this app requires OpenGL ES 3.0. -->
<uses-feature android:glEsVersion="0x00030000" android:required="true" />

Android Google Services

Android Google Maps

Android Google Map V2

Android Google Cloud Messaging (GCM)

Dans la console d'API Google principale, sélectionnez Accès API.

Google Cloud Messaging for Android : Google Cloud Messaging allows for push messaging to Android devices. Google Cloud Messaging for Android.