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

Preparing Android apps for Android Q.pdf

Preparing Android apps for Android Q.pdf

A look at the changes and features introduced in Android Q and how to adapt and add them to your app.

Avatar for Saurabh

Saurabh

June 22, 2019
Tweet

More Decks by Saurabh

Other Decks in Programming

Transcript

  1. Where are we? ➢ Decade of Android (10.0) ➢ Beta

    4 ➢ Final API’s ➢ API Level 29
  2. Background Activity Starts ➢ Affects - All apps running on

    Q (irrespective of target SDK) ➢ Exceptions: ◦ Bound services such as accessibility, auto-fill, etc. ◦ Receives a PendingIntent from system ◦ App had SYSTEM_ALERT_WINDOW permission ◦ App called finish() on activity very recently ➢ Recommended approach - Notification Triggered activity
  3. val fullScreenIntent = Intent(this, CallActivity::class.java) val fullScreenPendingIntent = PendingIntent.getActivity(this, 0,

    fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT) val notificationBuilder = NotificationCompat.Builder(this, CHANNEL_ID) .... .setPriority(NotificationCompat.PRIORITY_HIGH) .setCategory(NotificationCompat.CATEGORY_CALL) .setFullScreenIntent(fullScreenPendingIntent, true)
  4. ➢ Gotcha’s: ◦ System decides b/w notification & activity ▪

    Notification - User using the device ▪ Activity - Device Idle / when user interacts with notification ◦ Declare USE_FULL_SCREEN_INTENT permission
  5. Hardware Identifiers ➢ Affects - All apps running on Q

    (irrespective of target SDK) ◦ Exception thrown if Target SDK is Q ◦ null returned if Target SDK < Q ➢ Avoid: ◦ IMEI - TelephonyManager.getDeviceId() ◦ Mac Address ◦ ANDROID_ID - Settings.Secure.ANDROID_ID
  6. Hardware Identifiers ➢ Alternatives ◦ Advertising ID ◦ Instance ID

    - FirebaseInstanceId ◦ Globally-unique IDs (GUIDs) - UUID.randomUUID().toString()
  7. Settings Panel ➢ Bottom sheet for system settings ➢ Encourage

    app engagement ➢ Currently Supported: ◦ ACTION_INTERNET_CONNECTIVITY ◦ ACTION_WIFI ◦ ACTION_NFC ◦ ACTION_VOLUME ➢ AndroidX wrapper
  8. Gesture Navigation ➢ Affects - All apps running on Q

    (irrespective of target SDK) ➢ Recommended approach ◦ Draw Edge to Edge ◦ Override system gestures
  9. view.systemUiVisibility = //Layout as if the navigation bar was hidden

    View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or //Layout as if the status bar was hidden View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or //Layout at its most extreme View.SYSTEM_UI_FLAG_LAYOUT_STABLE
  10. root.setOnApplyWindowInsetsListener { _, insets -> val fabLp = fab.layoutParams as

    CoordinatorLayout.LayoutParams fabLp.bottomMargin = fabOriginalBottomMargin + insets.systemWindowInsetBottom fab.layoutParams = fabLp insets.consumeSystemWindowInsets() }
  11. ➢ System Gesture Insets ◦ New in Android Q ➢

    Draggable Views Insets.getSystemGestureInsets()
  12. root.setOnApplyWindowInsetsListener { _, insets -> val systemGestureInsets = insets.systemGestureInsets top.layoutParams

    = top.layoutParams.apply { height = systemGestureInsets.top } bottom.layoutParams = bottom.layoutParams.apply { height = systemGestureInsets.bottom } .... }
  13. ➢ Gotcha’s: ◦ Seekar & Drawer Layout work of the

    box ◦ Can opt out back gesture ◦ Home is reserved WindowInsets.getMandatorySystemGestureInsets()
  14. Dark Mode ➢ A new System Setting ◦ Under Settings->Display->Theme

    ◦ A Quick tile ◦ Battery Saver Mode ➢ Supported by 1.1 App Compat
  15. ➢ Gotcha’s: ◦ Test RemoteViews ◦ Configuration Change - uiMode

    ▪ UI will lose context if not handled properly ▪ Caution single orientation apps ▪ Media apps should handle to continue playback