Google I/O 2021 Android精華內容


Google I/O 2021結束了, 都有什么精彩內容呢?
Android部分的Playlist附上: Android & Play at Google I/O 2021

Developer Keynote (Google I/O '21)

對於Android的部分來說, 主要是:

Android 12

  • user safety.
  • performance; improved app startup; customizable launch animations.
  • user experience; widgets.

Create beautiful apps, easier

現代化的Android開發.

  • Android Studio的升級.
  • Kotlin: Kotlin Symbol Processing.
  • Jetpack: 各種libraries和Compose.

Build across screens.

  • 各種屏幕.
  • Voice.
  • Watches: Health services.

The top 3 things to know in Modern Android Development | Android @ Google I/O'21

Android開發的三個top topic:

  • Jetpack: 一系列的Jetpack libraries發布了新版.

01-Jetpack-libraries.png

  • Tooling: Android Studio的升級, 有了WorkManager Inspector, UI的Inspector支持了View和Compose.
  • Kotlin.

03-coroutines-flows.png

What's new in Android | Keynote

Android 12 -> S.

  • @Deprecated -> deprecated.
  • Color.
  • Widgets.
  • Launch animations: 系統自帶啟動動畫, 可以定制.
  • Notifications: 新的template style; Trampoline(?) 優化點開notification的那個短暫延遲.
  • Toasts: 帶icon, 說明是哪個app彈的toasts; 控制個數.
  • Picture in Picture的改善.
  • ImageView有個setRenderEffect可以模糊照片了.
  • 可以用theme定制模糊.

04-Blurry-Theme.png

  • list的彈力拉伸效果. (我自己起的名字, 其實人家叫stretch overscroll).
  • Graphics: AVIF. 可以過濾支持的media類型.
  • Privacy: 關於permission的一些改進; 剪貼板內容會有toast說明來源; foreground restrictions.

What’s new in Android development tools | Session

Android Studio版本號設計.

05-Android-Studio-Versions.png

  • Preview工具可以設置橫屏, 定制尺寸, 顯示blueprints, play animation. Compose的preview有交互模式.
  • Accessibility test framework scanner.
  • 適配多種屏幕: Layout validation.
  • 折疊屏, 手表.
  • 模擬器還可以模擬heart rate.
  • snapshots test.
  • WorkManager的tasks.
  • Migrate to Non-Transitive R Classes...

What’s new in Jetpack | Session

解釋了Jetpack的初衷和現狀.
alpha和beta版本的意思.

  • Experimental Annotations -> Stable.
  • CameraX -> Stable.
  • AppSearch -> Alpha.
  • DataStore -> 用來取代SharedPreferences.

06-datastore-1.png

  • Security Crypto -> Stable.
  • Hilt -> Stable.
  • WorkManager -> Stable. (Android Studio也推出了新的WorkManager Inspector.)
  • Room -> Stable.

08-room.png

  • ConstraintLayout -> Stable. MotionLayout + Motion Editor.
  • Fragment -> Stable.
    (詳見release notes: https://developer.android.com/jetpack/androidx/releases/fragment.)
    重建了FragmentManager; 新增了get result的callback; 廢棄了一些API, 並且Fragment StrictMode可以檢測項目中是否還在使用.
  • Navigation -> Alpha. 現在支持多個backstacks.
  • Google Shortcuts -> Alpha.
  • EmojiCompat -> Alpha. (AppCompat 1.4.0以后默認包含.)
  • Paging -> Stable.
  • Macrobenchmark -> Alpha. (app啟動和滾動效率; local/CI.)
  • Compose integrations.

09-compose-integrations.png

What's new in Jetpack Compose | Session

為什么我們需要一個全新的UI Toolkit呢. -> 為了適應更加現代化的開發方式.

faster & easier.

Compose將數據轉換成UI.

Checkbox的例子:

10-checkbox-snippet.png
UI完全由參數控制. -> single source of truth. 沒有其他的狀態需要sync.

把參數和回調提到方法參數中去:

11-checkbox-in-reality.png

  • You completely describe your UI for a given state.
  • The framework updates your UI when the state changes.

這里有個圖, 推薦ViewModel暴露一個Screen狀態, 集中管理, 然后下發到每個composable.

12-viewmodel-expose-single-state.png

這樣也利於測試.

Compose實現了material design, 提供了組件, 還有theming system.

有一個owl app的實現解說.

和傳統view的interop.

13-compose-view-interop.png

State of Kotlin on Android | Session

What’s new in Android Gradle plugin | Session

New APIs in the Android Gradle Plugin

Using Jetpack libraries in Compose | Session

Jetpack Compose和Jetpack中其他庫可以很好的結合使用.

18-compose-with-jetpack-libraries.png

Top 12 tips to get ready for Android 12 | Session

Getting Ready for Android 12.

  • Developer Options -> App Compatibility Changes.
  • Foreground services were designed for multi-tasking and completing a user action. -> 從后台啟動foreground services將被限制.
  • Expedited Jobs with WorkManager APIs.
  • User may turn off the mic and camera sensors using mic and camera toggles.
  • Apps that have not been used for an extended period will be hibernated. (permissions, storage, services)
  • Nearby device permission. Decouple Bluetooth scanning from Location.
  • MAC address restriction.
  • Safe component exporting. 有intent filter就必須顯式聲明exported.
  • Custom notifications deprecation.
  • App link improvements.
  • WebView Samesite.
  • New stretch overscroll.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM