Share
Embed
Rex - Migration Android 13
Présentation, agrémentée de mon retour d'expérience, de la liste des changements pour assurer la compatibilité des applications avec #Android13, la dernière version du système d’exploitation Android.
Robin Caroff
September 27, 2022
Transcript
45 slides
-
Rex - Migration Android 13 Robin Caroff Resonantes Édition #
21 Sponsorisé par 4 rue Voltaire (Nantes) Le Palace Nantes Mardi 27 septembre 2022 - 19H -
Runtime permission for notifications Permission ajoutée: <manifest ...> <!-- Required
only if your app targets Android 13 or higher. --> <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> <application ...> ... </application> </manifest> -
Changements de comportement Toutes les applications : • Runtime permission
for notifications • Dismissible foreground service notifications val builder = NotificationCompat.Builder( this, NotificationService.MY_CHANNEL_ID ) .setOngoing(true) -
Changements de comportement Toutes les applications : • Runtime permission
for notifications • Dismissible foreground service notifications • Foreground Services (FGS) Task Manager -
Changements de comportement Toutes les applications : • Runtime permission
for notifications • Dismissible foreground service notifications • Foreground Services (FGS) Task Manager • Improve prefetch job handling using JobScheduler -
Changements de comportement Toutes les applications : • Runtime permission
for notifications • Dismissible foreground service notifications • Foreground Services (FGS) Task Manager • Improve prefetch job handling using JobScheduler • Battery Resource Utilization -
Changements de comportement Toutes les applications : • Runtime permission
for notifications • Dismissible foreground service notifications • Foreground Services (FGS) Task Manager • Improve prefetch job handling using JobScheduler • Battery Resource Utilization • High Priority Firebase Cloud Message (FCM) Quotas -
Changements de comportement Toutes les applications : • Runtime permission
for notifications • Dismissible foreground service notifications • Foreground Services (FGS) Task Manager • Improve prefetch job handling using JobScheduler • Battery Resource Utilization • High Priority Firebase Cloud Message (FCM) Quotas • Hide sensitive content from clipboard -
Changements de comportement Les applications avec target Android 13 :
• La permission de notifications affecte le comportement des foreground services -
Changements de comportement Les applications avec target Android 13 :
• La permission de notifications affecte le comportement des foreground services • Runtime permission for nearby Wi-Fi devices : NEARBY_WIFI_DEVICES -
Changements de comportement Les applications avec target Android 13 :
• La permission de notifications affecte le comportement des foreground services • Runtime permission for nearby Wi-Fi devices • Granular media permissions -
Permission dépréciée: READ_EXTERNAL_STORAGE Remplacée par (en fonction du besoin) :
• Images et photos : READ_MEDIA_IMAGES • Vidéos : READ_MEDIA_VIDEO • Audio : READ_MEDIA_AUDIO -
Changements de comportement Les applications avec target Android 13 :
• La permission de notifications affecte le comportement des foreground services • Runtime permission for nearby Wi-Fi devices • Granular media permissions • Use of body sensors in the background requires new permission : BODY_SENSORS_BACKGROUND -
Changements de comportement Les applications avec target Android 13 :
• La permission de notifications affecte le comportement des foreground services • Runtime permission for nearby Wi-Fi devices : NEARBY_WIFI_DEVICES • Granular media permissions • Use of body sensors in the background requires new permission • Battery Resource Utilization -
Changements de comportement Les applications avec target Android 13 :
• La permission de notifications affecte le comportement des foreground services • Runtime permission for nearby Wi-Fi devices • Granular media permissions • Use of body sensors in the background requires new permission • Battery Resource Utilization • Media controls updates -
Changements de comportement Les applications avec target Android 13 :
• […] • Granular media permissions • Use of body sensors in the background requires new permission • Battery Resource Utilization • Media controls updates • Permission requise pour l’accès à l’advertising ID -
Permission requise pour l’accès à l’advertising ID <manifest ...> <!--
Required only if your app targets Android 13 or higher. --> <uses-permission android:name="com.google.android.gms.permission.AD_ID"/> <application ...> ... </application> </manifest> -
Permission requise pour l’accès à l’advertising ID <manifest ...> <uses-permission
android:name="com.google.android.gms.permission.AD_ID" tools:node="remove" /> <application ...> ... </application> </manifest> -
Changements de comportement Les applications avec target Android 13 :
• […] • Granular media permissions • Use of body sensors in the background requires new permission • Battery Resource Utilization • Media controls updates • Permission requise pour l’accès à l’advertising ID • Langue spécifique par application -
Langue spécifique par application <?xml version="1.0" encoding="utf-8"?> <locale-config xmlns:android="http://schemas.android.com/apk/res/android" >
<locale android:name="en"/> <locale android:name="en-GB"/> <locale android:name="fr"/> </locale-config> <manifest ...> <application android:localeConfigs="@xml/locales_config"> ... </application> </manifest> -
Nouvelles APIs • Photo picker val pickMedia = registerForActivityResult(PickVisualMedia()) {
uri -> if (uri != null) { Log.d("PhotoPicker", "Selected URI: $uri") } else { Log.d("PhotoPicker", "No media selected") } } pickMedia.launch(PickVisualMediaRequest(PickVisualMedia.ImageOnly)) -
Nouvelles APIs • Photo picker pickMedia.launch(PickVisualMediaRequest(PickVisualMedia.ImageAndVideo)) pickMedia.launch(PickVisualMediaRequest(PickVisualMedia.ImageOnly)) pickMedia.launch(PickVisualMediaRequest(PickVisualMedia.VideoOnly)) val mimeType
= "image/gif" pickMedia.launch(PickVisualMediaRequest(PickVisualMedia.SingleMimeType(mimeType))) -
Nouvelles APIs • Photo picker import android.os.ext.SdkExtensions.getExtensionVersion fun isPhotoPickerAvailable(): Boolean
{ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { true } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { getExtensionVersion(Build.VERSION_CODES.R) >= 2 } else { false } } -
Nouvelles APIs • Photo picker • Tile Service - request
add tile fun requestAddTileService ( tileServiceComponentName: ComponentName, tileLabel: CharSequence, icon: Icon, resultExecutor: Executor, resultCallback: Consumer<Int> ) -
Geocoder.getFromLocation(lat, lon, maxResults) fun getAddressFromCoordinates(latitude: Double, longitude: Double): String {
try { val geocoder = Geocoder(this, Locale.getDefault()) // Here 1 represent max location result to returned, by documents it recommended 1 to 5 val addresses: List<Address> = geocoder.getFromLocation(latitude, longitude, 1) return with(addresses[0]) { getAddressLine(0) } } catch (exception: Exception) { Timber.e(exception) } return "Unknown address" } DEPRECATED -
GeocoderListener geocoder.getFromLocation( latitude, longitude, 1, object : Geocoder.GeocodeListener { override
fun onGeocode(addresses: MutableList<Address>) { onGeocodeSuccess(addresses) } override fun onError(errorMessage: String?) { super.onError(errorMessage) Timber.w(errorMessage) onGeocodeError() } } ) -
Feedback Dites nous ce que vous en avez pensé !
https://openfeedback.io/SsApO1mL6wNRw2fGRKf3/2022-09-27