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

IO/Extended Yangon 2022 - What's new in Android?

IO/Extended Yangon 2022 - What's new in Android?

Aung Kyaw Paing

May 21, 2022
Tweet

More Decks by Aung Kyaw Paing

Other Decks in Technology

Transcript

  1. Aung Kyaw Paing What’s new in Android? Android 13, AS

    Electric Eel, Privacy Sandbox and much more
  2. User now has a choice to make app icons inherit

    the theme color Themed App Icons
  3. Built in photo pickers in OS. Using this picker doesn’t

    require READ_STORAGE permission. Photo Picker
  4. photo_picker.kt //If version > 13 val intent = Intent(MediaStore.ACTION_PICK_IMAGES) //Setup

    picker config //Launch Picker startActivityForResult(intent, PHOTO_PICKER_REQUEST_CODE)
  5. photo_picker.kt //If version > 13 val intent = Intent(MediaStore.ACTION_PICK_IMAGES) //Setup

    max count int maxCount = 5; intent.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, maxCount) //Launch Picker startActivityForResult(intent, PHOTO_PICKER_REQUEST_CODE)
  6. photo_picker.kt //If version > 13 val intent = Intent(MediaStore.ACTION_PICK_IMAGES) //Setup

    max count int maxCount = 5; intent.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, maxCount) //Set to video only intent.type = "video/*" //Launch Picker startActivityForResult(intent, PHOTO_PICKER_REQUEST_CODE)
  7. photo_picker.kt override fun onActivityResult(...) { //if result ok when (requestCode)

    { REQUEST_PHOTO_PICKER_SINGLE_SELECT -> { val currentUri: Uri = data.data // Do stuff with the photo/video URI. } REQUEST_PHOTO_PICKER_MULTI_SELECT -> { // Get photo picker response for multi select. data.clipData.forEach { clipData -> val uri = clipData.uri // Do stuff with the photo/video URI. } } } }
  8. photo_picker.kt override fun onActivityResult(...) { //if result ok when (requestCode)

    { REQUEST_PHOTO_PICKER_SINGLE_SELECT -> { val currentUri: Uri = data.data // Do stuff with the photo/video URI. } REQUEST_PHOTO_PICKER_MULTI_SELECT -> { // Get photo picker response for multi select. data.clipData.forEach { clipData -> val uri = clipData.uri // Do stuff with the photo/video URI. } } } }
  9. photo_picker.kt override fun onActivityResult(...) { //if result ok when (requestCode)

    { REQUEST_PHOTO_PICKER_SINGLE_SELECT -> { val currentUri: Uri = data.data // Do stuff with the photo/video URI. } REQUEST_PHOTO_PICKER_MULTI_SELECT -> { // Get photo picker response for multi select. data.clipData.forEach { clipData -> val uri = clipData.uri // Do stuff with the photo/video URI. } } } }
  10. User can select a different language for different apps and

    won’t always be tied to system language. App-specific locale
  11. language_pref.kt val localeList = AppCompatDelegate.getApplicationLocales() //Show custom picker with locale

    list //Set selected locale val appLocale: LocaleListCompat = LocaleListCompat.forLanguageTags("xx-YY") AppCompatDelegate.setApplicationLocales(appLocale)
  12. Notification will be opted-out by default. Apps need to request

    permission to send notification Notification Permission
  13. On newly installed app If the app targets Android 13

    - MUST ask permission explicitly If the apps targets Android 12 and lower - System will ask permission when first notification channel is created. Notification Permission
  14. On existing app A temporary grant is given if user

    has enabled notification before and has existing notification channel. If the app targets Android 13 - The grant lasts until user launches the app If the apps targets Android 12 and lower - The grant lasts until user select an option from permission prompt Notification Permission
  15. User can see all foreground services running under active app

    list in notification drawer Foreground Service Manager
  16. Foreground Service Manager Getting killed by FGS Manager does not

    kill your scheduled jobs and alarms. The system will alert user to interact with your active task if it runs for more than 20 hours in a day.
  17. Other changes “Restricted” bucket changes “NEARBY_WIFI_DEVICE” permission added Body sensor

    background permission added Quick Settings placement API Revoke permission API BLE Audio support MIDI 2.0 Color vector fonts
  18. A new privacy standard that allow users info to be

    private. Currently in design proposal stage Privacy Sandbox
  19. room_multimap.kt @Query("SELECT * FROM Artist JOIN Song ON Artist.artistName =

    Song.songArtistName") fun getArtistToSongs(): Map<Artist, List<Song>>
  20. Create profiles for your app that populate ahead of time

    compilation traces to reduce startup time and janks. Baseline Profile
  21. Emoji2 supports for latest emoji App-specific locale support from Android

    13 Play Splits to download additional locale AppCompat
  22. font_padding.kt Text( text = myText, style = TextStyle( lineHeight =

    2.5.em, platformStyle = PlatformTextStyle( includeFontPadding = false ), lineHeightStyle = LineHeightStyle( alignment = Alignment.Center, trim = Trim.None ) ) ) Set to true (left) and false (right)
  23. downloadable_font.kt @OptIn(ExperimentalTextApi::class) val provider = GoogleFont.Provider( providerAuthority = "com.google.android.gms.fonts", providerPackage

    = "com.google.android.gms", certificates = R.array.com_google_android_gms_fonts_certs ) val fontName = GoogleFont(“Lobster Two”) val fontFamily = FontFamily( Font(googleFont = GoogleFont(name), fontProvider = provider) )
  24. downloadable_font.kt @OptIn(ExperimentalTextApi::class) val provider = GoogleFont.Provider( providerAuthority = "com.google.android.gms.fonts", providerPackage

    = "com.google.android.gms", certificates = R.array.com_google_android_gms_fonts_certs ) val fontName = GoogleFont(“Lobster Two”) val fontFamily = FontFamily( Font(googleFont = GoogleFont(name), fontProvider = provider) )
  25. downloadable_font.kt val fontFamily = FontFamily( Font(googleFont = GoogleFont(name), fontProvider =

    provider, weight = weight = FontWeight.Bold, style = FontStyle.Italic) )
  26. A new code sample repo that showcase Modern Android Development

    See: https://github.com/android/nowinandroid
  27. write_data.kt suspend fun insertSteps(healthConnectClient: HealthConnectClient) { val records = listOf(

    Steps( count = 120, startTime = START_TIME, endTime = END_TIME, startZoneOffset = START_ZONE_OFFSET, endZoneOffset = END_ZONE_OFFSET, ) ) val response = healthConnectClient.insertRecords(records) }
  28. read_data.kt suspend fun readDataRange(client: HealthConnectClient) { val response = client.readRecords(

    ReadRecordsRequest( recordType = Steps::class, timeRangeFilter = TimeRangeFilter.between(START_TIME, END_TIME), ) ) response.records.forEach { // Process each entry } }
  29. View data from Google Play SDK index and provides lint

    checks if a SDK is outdated. SDK Insight
  30. Highlight codes that have relevant crash data. See stack traces,

    statistic, and link out to Crashlytics dashboard easily. Crashlytics
  31. Data Safety Provides information for users on what data you

    collect and why. Full rollout by July.