Slide 1

Slide 1 text

Explore new updates on Android Android 13, Compose, Large Screens Google Developer Expert (Android) Senior Engineer @ Lomotif Su Myat Tun Extended Singapore

Slide 2

Slide 2 text

Android 13 Mar Jul

Slide 3

Slide 3 text

Behaviour changes, new feature & APIs Android 13

Slide 4

Slide 4 text

Opt-in notification permission Applies to all newly installed apps, irrespective of targetSDK. For apps with targetSDK < 33, Android will typically ask for the Notification Permission on first launch. Notification Permission Privacy

Slide 5

Slide 5 text

App can’t send notification until user uninstall and reinstall your app Selects “Don’t allow”

Slide 6

Slide 6 text

Notification Permission ...

Slide 7

Slide 7 text

● Request when user is in-context ● Provide rationale before requesting permission ● No additional limits on prompting ● Check notification access through PermissionChecker, or NotificationManager.areNotificationsEnabled UX - Following Best Practices

Slide 8

Slide 8 text

Highly requested feature! Dismissable FGS Notifications

Slide 9

Slide 9 text

Foreground Services Task Manager ● Removes app from memory ● Stops media playback ● Stops the service, removing associated notification

Slide 10

Slide 10 text

No callback sent when user stop app ● REASON_USER_REQUESTED provided in ApplicationExitInfo API

Slide 11

Slide 11 text

Long Running FGS Notification ● Invites users to interact with Foreground Services Task Manager

Slide 12

Slide 12 text

Behavior “swipe up” and “force stop”

Slide 13

Slide 13 text

Other Permission Changes

Slide 14

Slide 14 text

● Similar to Bluetooth in Android 12 ○ Same permission group (NEARBY_DEVICES) ● NEARBY_WIFI_DEVICES instead of ACCESS_FINE_LOCATION Updates - Wi-Fi Location Minimization

Slide 15

Slide 15 text

Wi-Fi Location Minimization ...

Slide 16

Slide 16 text

Wi-Fi Permission - Backward compatibility

Slide 17

Slide 17 text

No longer support: ● READ_EXTERNAL_STORAGE ● WRITE_EXTERNAL_STORAGE Media Permission

Slide 18

Slide 18 text

Instead of READ_EXTERNAL_STORAGE: ● READ_MEDIA_IMAGE for images ● READ_MEDIA_VIDEO for video ● READ_MEDIA_AUDIO for audio Updates - Media Permission

Slide 19

Slide 19 text

If app requests READ_MEDIA_AUDIO: Updates - Audio Permission

Slide 20

Slide 20 text

If app requests both or only one permission at the same time: ● READ_MEDIA_IMAGE for images ● READ_MEDIA_VIDEO for video Updates - Media Permission

Slide 21

Slide 21 text

Changes - Media Permission

Slide 22

Slide 22 text

Storage Permission - Backward compatibility

Slide 23

Slide 23 text

Body Sensor - Need Background Permission ...

Slide 24

Slide 24 text

Intents - Non-matching Now Blocked Intents are only delivered from external apps to apps targeting Android 13 or higher when they match an element. There are a few exceptions: ● Components without Intent filters ● Intents from the system ● Intents from root

Slide 25

Slide 25 text

Preview - matching Intent //intent filter must specify element to accept intents with data val intent = Intent(“previewtwo”) intent.data = Uri.parse("https://android.com") startActivity(intent) +

Slide 26

Slide 26 text

Safer Runtime Broadcast Receivers // set new flag while registering a runtime receiver if not SecurityException will be thrown // I want to receive broadcasts from other apps! context.registerReceiver(broadcastReceiver, intentFilter, RECEIVER_EXPORTED); // I don’t want to receive broadcasts from other apps! context.registerReceiver(broadcastReceiver, intentFilter, RECEIVER_NOT_EXPORTED);

Slide 27

Slide 27 text

Battery Life is Important Following options appear in setting: Unrestricted Optimised(default) Restricted

Slide 28

Slide 28 text

Battery Life is Important Restricted: Favor device battery life over app versatility, places more limitations on what app can do in background

Slide 29

Slide 29 text

New Background Rules ● When the system places your app in the restricted ● What work your app can do when the user places your app in the restricted state. ● Check if you’re in one of the restricted states: ○ ActivityManager.isBackgroundRestricted () ○ UsageStatsManager.getAppStandbyBuck et()

Slide 30

Slide 30 text

Behavior Changes Summary Without targeting Android 13 ● FGS Task Manager ● Improved prefetch job handling ● Battery resource utilization ● Runtime notifications permission ● Media controls derived from PlaybackState ● In-app language pickers When targeting Android 13 ● Nearby Wi-Fi runtime permission ● Granular media permissions ● Background body sensors permission ● Intent filters block non-matching intents ● Battery resource utilization

Slide 31

Slide 31 text

Back better, Monochromatic Icon, much more Feature & APIs

Slide 32

Slide 32 text

● Ahead-of-time model allow the system to show preview of the destination ● Deprecated KEYCODE_BACK or onBackPressed APIs Predictable Back Gesture

Slide 33

Slide 33 text

Optional opt-in flag in the manifest: Android 13 The new back dispatching will be enabled by default for application targeting SDK 34 Android 14 Once the new behavior is enabled, KEYCODE_BACK and onBackPressed() won't be used anymore. Application will have to rely entirely on the OnBackInvokedCallback Jetpack supports the new Back API androidx.activity:activity:1.6.0 Opt in the new behavior

Slide 34

Slide 34 text

Themed App Icons ● Inherit the coloring of user’s choonse wallpaper ● Requires support for adaptive and monochromatic app icons

Slide 35

Slide 35 text

● Should be VectorDrawable ● logo fits within 44 x 44 inside 108 x 188, can up to 72 x 72 ● Flag logo Monochromatic icon specifications

Slide 36

Slide 36 text

● System settings let user can selects preferred language for your app, not coupling with System language ● API that let apps set different language at runtime Per-app Local Preferences

Slide 37

Slide 37 text

In-app language pickers AndroidManifest.xml res\xml\locales_config.xml

Slide 38

Slide 38 text

In-app Local Perference val appLocale: LocaleListCompat = LocaleListCompat.forLanguageTags("fr") // Call this on the main thread as it may require Activity.restart() AppCompatDelegate.setApplicationLocales(appLocale) //get in-app local language Val appLocale = AppCompatDelegate.getApplicationLocales() Update in-app local language

Slide 39

Slide 39 text

● Recommended way to access user’s photos and videos ● No runtime permissions ● Better UX to access photos & videos ● Continuously improved through Google Play System Updates ● Backported to Android 11 & 12 ● Will soon include cloud photos and albums Photo Picker

Slide 40

Slide 40 text

Using the Photo Picker // Launches photo picker in single-select mode. // This means that the user can select one photo or video. val intent = Intent(MediaStore.ACTION_PICK_IMAGES) startActivityForResult(intent, PHOTO_PICKER_REQUEST_CODE)

Slide 41

Slide 41 text

Using the Photo Picker // Launches photo picker in multi-select mode. // This means that the user can select multiple photos/videos, up to the limit. // specified by the app in the extra (10 in this example). val maxNum = 10 val intent = Intent(MediaStore.ACTION_PICK_IMAGES) intent.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX,maxNum) startActivityForResult(intent, PHOTO_PICKER_MULTI_SELECT_RC)

Slide 42

Slide 42 text

Handle the Photo Picker results // onActivityResult() handles callbacks from the photo picker. override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) { when(resultCode) { PHOTO_PICKER_REQUEST_CODE -> { // Get photo picker response for single select. val currentUri: Uri = data.data return } PHOTO_PICKER_MULTI_SELECT_RC -> { // Get photo picker response for multi select. var results = data.clipData return }

Slide 43

Slide 43 text

Downgradeable Permissions // Downgrade single permission @RequiresApi(33) fun revokeSelfPermissionOnKill(permName: String): Unit // Downgrade permission group @RequiresApi(33) fun revokeSelfPermissionOnKill(permissions:MutableCollection): Unit

Slide 44

Slide 44 text

● Copy and Past UI to Clipboard ● Provides a preview of the copied content ● Sensitive content to clipboard ● Programmable Shaders Other changes

Slide 45

Slide 45 text

Text View, Layout, Tools Features and Improvement in Compose

Slide 46

Slide 46 text

Downloadable Fonts Font Padding Text Magnifer Text improvements Compose 1.2

Slide 47

Slide 47 text

Compose 1.2 Downloadable Fonts @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(fontName), fontProvider = provider))

Slide 48

Slide 48 text

Compose 1.2 Text( text = myText, style = TextStyle( lineHeight = 2.5.em, platformStyle = PlatformTextStyle( includeFontPadding = false ), lineHeightStyle = LineHeightStyle( alignment = Alignment.Center, trim = Trim.None ) ) ) Set includeFontPadding true to left vs right fase and LineHeightSytle

Slide 49

Slide 49 text

Text Magnifier able to select text easier Compose 1.2

Slide 50

Slide 50 text

Lazy Layouts Nested Scrolling Window insets Shared Element Transitions Layout improvements Compose 1.2

Slide 51

Slide 51 text

Lazy Layouts Develop gradually with the grid APIs LazyVerticalGrid and LazyHorizontalGrid Compose 1.2 @Composable fun FavoriteCollectionsGrid( modifier: Modifier = Modifier ) { LazyHorizontalGrid( rows = GridCells.Fixed(2), modifier = modifier ) { items(favoriteCollectionsData) { item -> FavoriteCollectionCard(item.drawable, item.text) } } }

Slide 52

Slide 52 text

Nested Scrolling Interop Scrolling composable in Coordinator layout is much smoother Things like Collapsing Toolbar are easy to set up Compose 1.2

Slide 53

Slide 53 text

Window insets Graduated from Accompanist to Compose Foundation Compose 1.2

Slide 54

Slide 54 text

Shared Element Transitions WIP

Slide 55

Slide 55 text

Tools Live Edit Recomposition debugging

Slide 56

Slide 56 text

Live Edit Immediately reflected code changes

Slide 57

Slide 57 text

Recomposition debugging

Slide 58

Slide 58 text

Android 12L & 13, developer resources, Multi-tasking, jetpack collection libraries apps adaptability for all screen sizes

Slide 59

Slide 59 text

Material guidelines https://goo.gle/large-screens-guidelines App quality guidelines https://goo.gle/ls-app-quality Compatibility checklist https://goo.gle/ls-checklist Quality matters

Slide 60

Slide 60 text

Android 12L & 13 Improved taskbar for app switching Allow Drag and Drop Resizable Window Don’t assume your app will be only used in a certain orientation Don’t assume your app will be only used through a touch screen Multi-window by default Compatibility mode Input support

Slide 61

Slide 61 text

a lot of broken assumptions means a lot of code to be changed in your app? Development Changes

Slide 62

Slide 62 text

Jetpack WindowManager: stable release, provide common API surface for supporting different device types, starting with foldables and tablet Window Metrics: access currentWindowMetric, maxWindowMetric in advance Window size classes: provide opinionated layout breakpoints for you to know how to adapt your UI based on screen size, partition as compact, medium, expended Activity embedding: allows displaying two Activities simultaneously, with each taking up a portion of the window. SlidingPaneLayout: Places content side by side if the window size allows Resizable and desktop emulators Large Screens made easy

Slide 63

Slide 63 text

Thank you! Google Developer Expert (Android) Senior Engineer @ Lomotif @su_myat_tun Su Myat Tun Extended Singapore