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

Android 11 Meetups: Whats New In Android

Android 11 Meetups: Whats New In Android

A summary of new things in Android 11 Developers need to know.

David Odari

July 04, 2020
Tweet

More Decks by David Odari

Other Decks in Programming

Transcript

  1. GDG Location So… what is new? What’s new about What’s

    New in Android? Android 11 GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS Libraries Tools
  2. GDG Location Window Insets • More information about the multiple

    types of content being displayed APP Status Navigation IME GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  3. GDG Location WindowInsets // get WindowInsets object from listener view.setOnApplyWindowInsetsListener

    { view, insets -> } GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  4. GDG Location WindowInsets // get WindowInsets object from listener view.setOnApplyWindowInsetsListener

    { view, insets -> // See if the IME is visible val imeVisible = insets.isVisible(WindowInsets.Type.ime()) // See if the navigation bars are visible val navInsets = insets.isVisible(WindowInsets.Type.navigationBars()) } GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  5. GDG Location WindowInsets // get WindowInsets object from listener view.setOnApplyWindowInsetsListener

    { view, insets -> val imeVisible = insets.isVisible(WindowInsets.Type.ime()) if (imeVisible) { val imeInsets = insets.getInsets(WindowInsets.Type.ime()) // ... } } GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  6. GDG Location IME Animations • Synchronize keyboard animations with app

    content changes ◦ Listen for changes ▪ AND/OR ◦ Drive keyboard animation directly GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  7. GDG Location editText.setWindowInsetsAnimationCallback(animCallback) val animCallback = object : WindowInsetsAnimation.Callback(DISPATCH_MODE_STOP) {

    override fun onProgress(p0: WindowInsets, p1: MutableList<WindowInsetsAnimation> ): WindowInsets { ... } // Optional overrides override fun onPrepare(animation: WindowInsetsAnimation) { ... } override fun onEnd(animation: WindowInsetsAnimation) { ... } override fun onStart(animation: WindowInsetsAnimation, bounds: WindowInsetsAnimation.Bounds ): WindowInsetsAnimation.Bounds { ... } } IME Animations Listening for keyboard changes GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  8. GDG Location IME Animations editText.windowInsetsController?. controlWindowInsetsAnimation( WindowInsets.Type.ime(), /* animate the

    keyboard */ -1, /* infinite duration */ linearInterpolator, /* linear motion */ cancellationSignal, /* allows cancellation */ animationControlListener /* ready/cancelled/finished */ ) Animating the keyboard directly GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  9. GDG Location Conversations // Create Person Object val person =

    Person.Builder().build() GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS // Other options in builder val person = Person.Builder() .setBot(true) .setName(“David”) .setImportant(false) .setIcon(null) .setKey(“Ab43byuHAj9UO89O”) //... .build()
  10. GDG Location Conversations // Create and post shortcut val person

    = Person.Builder().build() val shortcutInfo = ShortcutInfoCompat.Builder(this, "sampleShortcut") .setPerson(person) .setLongLived(true). // ... build() GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  11. GDG Location Conversations // Create and post shortcut val person

    = Person.Builder().build() val shortcutInfo = ShortcutInfoCompat.Builder(this, "sampleShortcut") .setPerson(person) .setLongLived(true). // ... build() ShortcutManagerCompat.pushDynamicShortcut(shortcutInfo) GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  12. GDG Location Conversations // Create and post shortcut val person

    = Person.Builder().build() val shortcutInfo = ShortcutInfoCompat.Builder(this, "sampleShortcut") .setPerson(person) .setLongLived(true). // ... build() ShortcutManagerCompat.pushDynamicShortcut(shortcutInfo) // Create notification with shortcut val style = NotificationCompat.MessagingStyle(person). addMessage(...). // ... GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  13. GDG Location Conversations // Create and post shortcut val person

    = Person.Builder().build() val shortcutInfo = ShortcutInfoCompat.Builder(this, "sampleShortcut") .setPerson(person) .setLongLived(true). // ... build() ShortcutManagerCompat.pushDynamicShortcut(shortcutInfo) // Create notification with shortcut val style = NotificationCompat.MessagingStyle(person). addMessage(...). // ... NotificationCompat.Builder(this, "foo"). setShortcutId(shortcutInfo.id). // ... build() GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  14. GDG Location Bubbles • Notifications that can also show as

    bubbles • Android 10: Developer option ◦ Android 11: They’re here! • Better than System Alert Window! • Created with Notification API ◦ with more metadata ◦ and dedicated activity GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  15. GDG Location Bubbles: Code // Create Intent to launch val

    intent = Intent(context, BubbleActivity::class.java) val bubbleIntent = PendingIntent.getActivity(context, 0, intent,...) GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  16. GDG Location Bubbles: Code // Create Intent to launch val

    intent = Intent(context, BubbleActivity::class.java) val bubbleIntent = PendingIntent.getActivity(context, 0, intent,...) // Create metadata val shortcutInfo = ... /* probably already using for notifications */ val bubbleMetadata = Notification.BubbleMetadata.Builder(shortcutInfo.id) . .setIcon(Icon.createWithResource(context,R.drawable.icon) .setDesiredHeight(800) .build() GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  17. GDG Location Bubbles: Code // Create Intent to launch val

    intent = Intent(context, BubbleActivity::class.java) val bubbleIntent = PendingIntent.getActivity(context, 0, intent,...) // Create metadata val shortcutInfo = ... /* probably already using for notifications */ val bubbleMetadata = Notification.BubbleMetadata.Builder(shortcutInfo.id) // Create Notification with metadata val builder = Notification.Builder(context, CHANNEL_ID) // ... .setBubbleMetadata(bubbleMetadata) .setCategory(...) .setShortcutId(...) GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  18. GDG Location What’s new in System UI Android Samples on

    Github: user-interface-samples/People 140: Bubbles! GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  19. GDG Location Privacy Android 11 enables state of the art

    privacy and security features, protecting users and their data from access by malicious apps, while simultaneously making access of that data more transparent to the user. GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  20. GDG Location Data Access Auditing • Listen for when user-permission-required

    data is accessed • Great for large apps or use of external libraries GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  21. GDG Location • Callbacks invoked when user-permission-required data is accessed

    Data Access Auditing GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  22. GDG Location Data Access Auditing val appOpsCallback = object :

    AppOpsManager.OnOpNotedCallback() { override fun onNoted(syncNotedAppOp: SyncNotedAppOp) { ... } override fun onSelfNoted(syncNotedAppOp: SyncNotedAppOp) { ... } override fun onAsyncNoted(asyncNotedAppOp: AsyncNotedAppOp) { ... } } GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  23. GDG Location Data Access Auditing val appOpsCallback = object :

    AppOpsManager.OnOpNotedCallback() { override fun onNoted(syncNotedAppOp: SyncNotedAppOp) { ... } override fun onSelfNoted(syncNotedAppOp: SyncNotedAppOp) { ... } override fun onAsyncNoted(asyncNotedAppOp: AsyncNotedAppOp) { ... } } val appOpsManager = getSystemService(AppOpsManager::class.java) as AppOpsManager appOpsManager.setOnOpNotedCallback(mainExecutor, appOpsCallback) GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  24. GDG Location • More restrictive in Android 11 • First,

    request foreground permission • Then request background permission ◦ Takes user to Settings Background Location GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  25. GDG Location • Android 10 required manifest attribute for Location

    • Android 11 adds ◦ Camera ◦ Microphone Foreground Services GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  26. GDG Location But Wait, There’s More! • Package visibility restrictions

    • Scoped storage • Auto-reset permissions GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  27. GDG Location Wi-Fi Debugging Because there are never enough USB

    ports GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  28. GDG Location Wi-Fi Debugging Because there are never enough USB

    ports GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  29. GDG Location 5G • APIs to optimize 5G experience ◦

    Metered network state ◦ Bandwidth estimates GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  30. GDG Location 5G val manager = getSystemService(ConnectivityManager::class.java) manager.registerDefaultNetworkCallback(object: ConnectivityManager.NetworkCallback() {

    override fun onCapabilitiesChanged(network: Network, capabilities: NetworkCapabilities) { if (capabilities.hasCapability( NetworkCapabilities.NET_CAPABILITY_NOT_METERED)) {...} ... if (capabilities.linkDownstreamBandwidthKbps > FAST_NETWORK) {...} } }) GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  31. GDG Location Autofill/Keyboard Integration • Autofill content in keyboards, not

    just drop-down ◦ Keyboards ◦ Password apps • Secure - keyboards get UI to present data, not data itself GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  32. GDG Location Autofill: Keyboards // Implement InputMethodService methods // Autofill

    request from IME override fun onCreateInlineSuggestionsRequest(uiExtras: Bundle): InlineSuggestionsRequest? { // ... } GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  33. GDG Location Autofill: Keyboards // Implement InputMethodService methods // Autofill

    request from IME override fun onCreateInlineSuggestionsRequest(uiExtras: Bundle): InlineSuggestionsRequest? { // ... } // Autofill response override fun onInlineSuggestionsResponse(response: InlineSuggestionsResponse): Boolean { // ... } GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  34. GDG Location Autofill: Password Apps // AutofillServices handle onFillRequest(), create

    FillResponse with InlinePresentation override fun onFillRequest(...) { } GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  35. GDG Location Autofill: Password Apps // AutofillServices handle onFillRequest(), create

    FillResponse with InlinePresentation override fun onFillRequest(...) { val datasetBuilder = Dataset.Builder() val inlinePresentation = InlinePresentation(...) datasetBuilder.setValue(..., inlinePresentation, ...) } GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  36. GDG Location Autofill: Password Apps // AutofillServices handle onFillRequest(), create

    FillResponse with InlinePresentation override fun onFillRequest(...) { val datasetBuilder = Dataset.Builder() val inlinePresentation = InlinePresentation(...) datasetBuilder.setValue(..., inlinePresentation, ...) responseBuilder = FillResponse.Builder() val fillResponse = responseBuilder.addDataset(datasetBuilder.build()). // ... .build() // ... } GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  37. GDG Location Jetpack • 70+ libraries, releases every two weeks

    • New/Recent ◦ Hilt: Dependency injection, built on Dagger ◦ Paging 3.0: All-Kotlin, with coroutines ◦ CameraX Beta ◦ … and more! GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  38. GDG Location Jetpack Compose • New UI Toolkit for Android

    • Reactive, Kotlin-based • Pre-alpha, developed in the open GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  39. GDG Location Repos to checkout on Github: hittherejoe/ComposeAcademy -Playground ditn/Doom-Compose

    Get Started: https://codelabs.developers.google.com/codelabs/jetpac k-compose-basics/#0 GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  40. GDG Location Android Studio • 4.0: Stable ◦ Motion Editor

    ◦ LayoutInspector • 4.1: Beta ◦ Database Inspector (Room, SQLite) • 4.2: Canary ◦ Wireless debugging with Android 11 ◦ Jetpack Compose development GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  41. GDG Location Google Play • New Play console: complete redesign

    ◦ clearer, easier to use ◦ policy status section ◦ acquisition reports ◦ team management • Now in Beta ◦ play.google.com/console GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS
  42. GDG Location Lots of other cool stuff - Nullability Annotations

    - Crash Reasons Reporting - Neural Networks API - Graphics and media - ADB Incremental GDG MAKURDI, GDG LAFIA, GDG KEFFI ANDROID 11 MEETUPS