Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What's new in Android 2018

What's new in Android 2018

This a deck that Google provide to share what is new in Android 2018.

1b77dd441f657f5aefb3e21283b252e6?s=128

GDG Montreal

November 25, 2018
Tweet

Transcript

  1. What’s new in Android @L_de_V Laurence de Villers

  2. What’s New In Android PI A s

  3. Android App Bundle

  4. Source: Partner provided data 5 10 15 20 25 30

    35 40 45 50 55 60 65 70 75 80 85 90 95 100 APK size (MBs) Conversion rate decreases as apps get larger Play Store conversion rate (% of visitors who install) Trendline
  5. xxhdpi hdpi xhdpi mdpi ldpi xxxhdpi

  6. xxhdpi arm hdpi arm xhdpi arm mdpi arm ldpi arm

    xxxhdpi arm xxhdpi x86 hdpi x86 xhdpi x86 mdpi x86 ldpi x86 xxxhdpi x86
  7. xxhdpi arm64 hdpi arm64 xhdpi arm64 mdpi arm64 ldpi arm64

    xxxhdpi arm64 xxhdpi arm hdpi arm xhdpi arm mdpi arm ldpi arm xxxhdpi arm xxhdpi x86 hdpi x86 xhdpi x86 mdpi x86 ldpi x86 xxxhdpi x86 xxhdpi x86_64 hdpi x86_64 xhdpi x86_64 mdpi x86_64 ldpi x86_64 xxxhdpi x86_64
  8. xxhdpi arm64 v:14 hdpi arm64 v: 16 xhdpi arm64 v:15

    mdpi arm64 v:17 ldpi arm64 v:18 xxxhdpi arm64 v:13 xxhdpi arm v:20 hdpi arm v:22 xhdpi arm v:21 mdpi arm v:23 ldpi arm v:24 xxxhdpi arm v:19 xxhdpi x86 v: 8 hdpi x86 v:10 xhdpi x86 v:9 mdpi x86 v: 11 ldpi x86 v:12 xxxhdpi x86 v: 7 xxhdpi x86_64 v: 2 hdpi x86_64 v: 4 xhdpi x86_64 v:3 mdpi x86_64 v:5 ldpi x86_64 v: 6 xxxhdpi x86_64 v: 1
  9. Android App Bundle Benefit from a smaller app Stop managing

    multiple APKs Deliver features on-demandBETA
  10. Source: Partner provided data saving 11% saving 23% saving 45%

    saving 22% 28% saving ABA English Airbnb LinkedIn Perigee saving 49% RV AppStudios saving 64% Memrise Pluto. TV
  11. Optimized APK for each device Upload an Android App Bundle

    Dynamic Delivery
  12. /res/xxxhdpi classes.dex /res/xxhdpi config_xxxhdpi.apk base.apk config_xxxhdpi.apk /res/xhdpi /res/hdpi config_xhdpi.apk config_hdpi.apk

    /res/mhdpi /res/ldpi config_mhdpi.apk config_ldpi.apk /lib/x86 /lib/arm config_x86.apk config_arm.apk /res/values-en /res/values-fr config_en.apk config_fr.apk /res/values-es config_es.apk …
  13. App Bundle APK

  14. Android App Bundle Start today at g.co/androidappbundle

  15. Android Jetpack Accelerate App Development

  16. None
  17. 95% supported devices

  18. Refactor android.support.v4.* android.support.v7.* // etc. androidx.*

  19. Jetpack Architecture

  20. Jetpack Architecture Lifecycle Lifecycle Aware Components

  21. Jetpack Architecture Lifecycle Lifecycle Aware Components ViewModel View data decoupled

    from OS lifecycle
  22. Jetpack Architecture Lifecycle Lifecycle Aware Components ViewModel View data decoupled

    from OS lifecycle Room SQLite object mapping
  23. Jetpack Architecture Lifecycle Lifecycle Aware Components ViewModel View data decoupled

    from OS lifecycle Room SQLite object mapping LiveData Lifecycle aware observables
  24. Jetpack Architecture Lifecycle Lifecycle Aware Components ViewModel View data decoupled

    from OS lifecycle Paging (1.0!) Asynchronous data retrieval Room SQLite object mapping LiveData Lifecycle aware observables
  25. Jetpack Architecture WorkManager Job scheduling Navigation Backstack and app flows

    PREVIEW
  26. View Models Simplifying Android development

  27. What is the hardest part of Android Development?

  28. None
  29. ViewModel onCleared()

  30. ViewModel + LiveData onCleared() observe LiveData

  31. ViewModel + LiveData onCleared() LiveData observe

  32. ViewModel + LiveData onCleared() LiveData observe

  33. ViewModel + LiveData onCleared() LiveData

  34. ViewModel + LiveData onCleared() LiveData observe

  35. ViewModel + LiveData onCleared() LiveData observe

  36. ViewModel + LiveData onCleared() LiveData observe

  37. ViewModel + LiveData onCleared() LiveData

  38. Room A better way to do databases

  39. 2016: How do you do Databases on Android?

  40. Database SQLite App Logic Content Provider

  41. Database Uri App Logic Content Provider SQLite

  42. Database Content Values Uri App Logic Content Provider SQLite

  43. App Logic Content Provider Database Content Values Uri SQLite Not

    type-safe
  44. App Logic Content Provider Database Content Values Uri SQLite Not

    type-safe Not type-safe
  45. App Logic Content Provider Database Content Values Uri SQLite Not

    type-safe Not type-safe
  46. Room Database App Logic Content Provider Content Values Uri Not

    type-safe Not type-safe SQLite
  47. Room DAO SQLite

  48. Room SQL DAO View Model SQLite Type-safe

  49. Room SQL Entities DAO View Model Type-safe Type-safe SQLite

  50. WorkManager Backwards compatible background work PREVIEW

  51. Battery Optimizations Optimize background tasks to stay charged longer

  52. Unlimited Background Services Doze App Standby Limited Broadcasts Release Wakelocks

    Service Limitations App Standby Buckets Background Restrictions
  53. There is still a lot of work to do Sending

    logs Uploading images and videos Syncing data Processing data
  54. Basic Work: upload a photo upload

  55. // A simple Worker class UploadPhotoWorker : Worker() { override

    fun doWork(): WorkerResult { uploadPhoto() return WorkerResult.SUCCESS } } SUCCESS FAILURE RETRY Runs on a background thread
  56. // Creating a work request and enqueuing it val request:

    WorkRequest = OneTimeWorkRequestBuilder<UploadPhotoWorker>().build() WorkManager.getInstance().enqueue(request) Ω
  57. What if you lose connectivity? Use constraints!

  58. // Creating a work request with network constraints val constraints

    = Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) .build() val request = OneTimeWorkRequestBuilder<UploadPhotoWorker>() .setConstraints(constraints) .build() WorkManager.getInstance().enqueue(request)
  59. Show Progress upload

  60. Chain Work compress upload

  61. Parallel Work upload

  62. Complex Flows filter filter filter compress upload

  63. When to use? Best-Effort Exact Timing ThreadPool Coroutines ThreadPool Coroutines

  64. When to use? Best-Effort Guaranteed Execution Exact Timing Deferrable ThreadPool

    Coroutines ThreadPool Coroutines Foreground Service
  65. WorkManager Respects users battery Works with OS Backwards compatible (API14)

  66. Navigation How to get around your app PREVIEW

  67. Challenges for navigation Fragment Transactions Deep Links Passing Arguments Up

    and Back Errorprone Boilerplate Testing
  68. Home Category Item https://... Need to be created and added

    to back stack on deep link
  69. Navigation Graph A navigation graph is a blueprint of screens

    and the actions that link them.
  70. Navigation Define navigation graph with visual tool / XML: Make

    a single navigate() call and runtime library handles everything
  71. None
  72. Safe Args Type-safe arguments when launching a Fragment

  73. HelpFragment.kt if (!arguments.containsKey("screenName")) { throw IllegalArgumentException() } val category: Int

    = arguments.getInt("category") val screenName: String = arguments.getString("screenName")
  74. HomeFragment.kt findViewById<Button>(R.id.help_button).setOnClickListener { v -> val helpDirections = HomeFragmentDirections.help("Home") helpDirections.category

    = 1703 v.findNavController().navigate(helpDirections) }
  75. HelpFragment.kt val args : HelpFragmentArgs = HelpFragmentArgs.fromBundle(arguments) val screenName: String

    = args.screenName val category: Int = args.category
  76. Navigation IDE tooling for app navigation Manage deeplinks Safe argument

    passing
  77. Jetpack Architecture Start today at d.android.com/arch

  78. Integration Tests e2e Tests Unit Tests Android Test Part of

    Jetpack
  79. @RunWith(AndroidJUnit4::class) class SimpleUnifiedTest { @Test fun viewIsVisible() { assertEquals(view.visibility, View.VISIBLE)

    } } Failed: Expected 0 but was 16 F
  80. @RunWith(AndroidJUnit4::class) class SimpleUnifiedTest { @Test fun viewIsVisible() { assertThat(view).isVisible() }

    } Failed: View was not visible F NEW
  81. Core Platform changes in Android Pie

  82. Battery App Standby Buckets usage based access to jobs, alarms,

    network, messaging Background Restriction user can restrict badly-behaved apps
  83. Background Inputs & Privacy

  84. Kotlin Performance & Compiler ART, D8, R8 Nullability support library

    and libcore
  85. Android KTX Part of Jetpack Concise, readable code. A suite

    of libraries Android KTX, Testing KTX, ...
  86. Background Text Measurement Text measurement is expensive Up to 80

    to 90% of the draw/measure/layout loop Pre-computed text API offloads most of the work to a worker thread PrecomputedText.create(...)
  87. Baseline distance

  88. val tv: TextView // Distance from top to first baseline

    tv.firstBaselineToTopHeight = distancePx // Distance from bottom to last baseline tv.lastBaselineToBottomHeight = distancePx NEW
  89. Security Unified BiometricDialog @deprecated FingerprintManager Stronger protection for private keys

    StrongBox backend Build.SERIAL doesn’t work anymore
  90. System UI Integrating fully with Android

  91. Display Cutouts Simulate notches in developer options (skip the electrical

    tape) WindowInsets#getDisplayCutout() android:windowLayoutInDisplayCutoutMode • mode=”never” • mode=”default” • mode=”shortEdges” + DisplayCutout#getSafeInsets() • mode=”shortEdges” + DisplayCutout#getBounds()
  92. Slices A new approach to remote content • Within an

    app or between apps • Structured data, flexible templates • Interactive, updatable • Backwards-compatible! • (Support Library, KitKat/API 19+)
  93. Actions Deep links into your app • “shortcuts with parameters”

    • “a visible Intent” Define actions in actions.xml Register with App Indexing to show as on-device search results
  94. Notifications People love messages …so we focused on MessagingStyle •

    Inline images/stickers • Participant images • Smart reply UI • RemoteInput.setChoices() And more!
  95. What’s New In Android Android App Bundle https://g.co/androidappbundle Android Jetpack

    https://d.android.com/jetpack https://d.android.com/kotlin https://d.android.com/arch https://d.android.com/arch/navigation https://d.android.com/arch/workmanager Core Platform App Standby Buckets Background Restrictions System UI Display Cutouts Slices & Actions Notifications
  96. Thank You!