Posted by: Kirill Rozov
The Google I/O’21 conference took place, and we learned absolutely everything about the new version of Android, and we can also try it all in Beta 1, which we can install on the Pixel, and other manufacturers also allow you to install the GSI image.
The main emphasis in the release was made on enhancing OS security and data privacy, as well as redesigning the system. They have done a very good job of supporting today’s new media standards, and they have minimized the amount of pain that flagship devices will experience from older or budget smartphones. App Widgets have been improved, as users have been asking for since the first version of Android.
Google has unveiled an updated version of Material Design that focuses on personalizing the color palette. For example, colors in Pixel devices will be determined based on the background image. You will be able to fully experience Material You in the second Beta version of Android 12.
The most important question is: “How will vendors adapt Material You in their firmware?” The chances are that this concept of colors will remain in pure Android, and vendors and third-party applications will ignore the design and use their own ideas. The entire color palette in Material was based on the app’s brand colors, and now it has to be user-definable. Much depends on how the app interface designers adapt the new design. Write in the comments if you like Google’s new visual style
Standard Splash Screen for all apps
SplashScreen API allows you to customize it for your brand: set a background, animated icon and other parameters. You cannot turn off the new Splash Screen, so everyone who has their own variation of such a screen — pay attention.
Splash Screen is a fairly popular practice in Android applications to hide long initialization. Now a standard Splash Screen appears in Android, which will animate the opening of the application from the icon to the launcher.
Updating UI effects
The design update has affected many aspects of the UI system, even the Ripple effect has been updated. Now it has a “white noise” effect on the edges. I liked the old one-color Ripple, and the new Ripple looks weird and unnatural.
A new effect when reaching the boundaries in the list became available in Android 12 for the native (Android View) system. Overscroll will be very familiar to those using the iOS new effect.
A new API that will allow you to make blurs, color filters, and other graphic effects much easier and more efficient. Now you can achieve window blur with just one line of API.
// Setting the effect for any View view.setRenderEffect( RenderEffect.createBlurEffect(radiusX, radiusY, SHADER_TILE_MODE) )// Blurring Window background from code Window.setBackgroundBlurRadius(radius: Int)// Setting background blur in a theme <style name="AppTheme"> <item name="android:windowBackgroundBlurRadius">15dp</item></style>
In Android 12, the Desktop Widgets API has been significantly overhauled. It seems to me that the appearance of this functionality in iOS 14 pushed Google to pay attention to developer complaints about this API from the very first version of Android. Here’s what has now appeared:
- Rounded edges on the background of all widgets on Android 12+
- Widgets can use dynamic colors from the theme, which are new to Material You
- Initial widget setup may be optional and you may skip this step
- CheckBox, Switch and RadioButton support has been added. Various Todo lists and applications with settings via toggle switches
<appwidget-provider … android:targetCellWidth=”3" android:targetCellHeight=”2" android:maxResizeWidth=”250dp” android:maxResizeHeight=”110dp” />
- Now you can put not only a static image on the preview of the widget, but also layout the UI in XML and add a description
<appwidget-provider … android:previewLayout=”@layout/my_widget_preview" android:description=”@string/my_widget_des" />
- Animations when the application is opened by clicking on the widget. The background of the widget will be transformed into the background of the window of the opened Activity
- Simplifying the API for working with lists in widgets
- The Great Backward Compatibility Guide for Widgets Before and After Android 12
We are also promised a library for writing widgets in DSL style, similar to Compose, with support for older versions of Android. This will be a special DSL that will be converted into the View hierarchy, but I’m already pleased that the Compose style will be implemented into the existing functionality of the system as well.
Rounded Corner API
The Rounded Corner API will allow you to get information about rounded displays and position your content securely so it doesn’t get clipped.
The example Google gives for offsetting content based on the information about the roundings doesn’t look small, but now we at least have the option.
Rich Content Insertion
Sharing content between different applications is an important feature of any system. Google makes life easier for developers and now we have one API for inserting content — Rich Content Insertion — instead of three separate APIs for inserting content via drag-&-drop, images from the keyboard and the clipboard. Also the compat API OnReceiveContentListener is already added in Jetpack Core 1.5.0 which is released in Stable.
Android updates have also touched on the overhaul of notifications. Their template changed again and several new features appeared:
- In MessagingStyle and BigPictureStyle you can add animated pictures
- You can require mandatory user authorization before sending the Intent
- New call notification style CallStyle, which allows you to create different styles for incoming, outgoing and ongoing calls. You can also set the importance for calls
- The area in the notification allocated for Custom View is now getting smaller
Prohibiting «springboard» in notifications
A springboard is a case when clicking on a notification launches an Activity, but this is not done directly. For example, you first start BroadcastReceiver, and Activity starts from it. This is now banned to improve performance and UX. If you want to launch an Activity from a notification, do it directly. Otherwise, nothing will happen, and there will be an error in the logs.
Support for images of the AV1 format, or rather AVIF files. This format comes from video and takes full advantage of compression and provides higher image quality and detail at the same size as JPG. Will we be able to shoot photos in this format?
Compatible Media Transcoding
In Android 12, the ability for any application to play modern video formats appears. Android will be able to convert HEVC (H.265) to AVC (H.264) as well as HDR10 to SDR. You need to create a new XML file in your application resources describing support for modern formats, and then add a link to it in the AndroidManifest.
The new feature allows devices to create videos in modern formats on devices and convert them automatically so that there are no problems with using such content for applications.
The video conversion speed is fast — a one minute video at 1080p and 30 frames per second converts in 9 seconds on a Pixel 4. Let me remind you that the Pixel 4 has the flagship Snapdragon 845 processor and 6GB of RAM. Therefore, the results on devices with a class below may be worse(
Starting with Android 12, a new Performance Class standard appears. It describes a set of device capabilities that are the minimum required capabilities for the Android version. Developers can check the performance class and change settings to provide the best user experience for the user’s device.
Class 12 will be published with the Android 12 release and will include requirements for video playback capabilities, content shooting capabilities, display specifications, disk read/write speeds, and RAM. The class will increase with each new version, and the requirements will be updated, but Class 12 may remain even on Android 13 if the new requirements are not met.
- Vibration feedback generation based on audio stream. It will be very useful for games
- The ability to use a high-resolution camera has been added, meaning you can capture 108 megapixels and other huge sizes.
- When switching audio between applications, the volume will fade instead of an abrupt pause.
- Camera2 API now contains extensions for using special modes similar to CameraX Extentions
Security and privacy
In Android 11, you can now give permission to access geolocation only while using the app and for one time. 80% of users took advantage of these opportunities. Google is developing the idea of user control of application access to location. On Android, you can request the exact and approximate location, and now the user can refuse, but give access to the approximate location when requesting the exact position.
The change will only work for applications with targetSdk=S, as developers of applications requesting access to the exact location need to change their code.
If you need an exact location, and the user has previously provided an approximate location, then the user will be prompted to give you access only to the exact location when asked again.
Separate permission for Nearby scanning via Bluetooth
If you wanted to scan a nearby device using Bluetooth in current versions of Android, you had to ask for permission to access the location, which sometimes confused users. But in Android 12 these permissions will be split into new ones: BLUETOOTH_SCAN and BLUETOOTH_CONNECT. BLUETOOTH_SCAN is used for access when searching for Bluetooth devices, and BLUETOOTH_CONNECT is used when you need to connect to already paired devices.
If you still need crawl-based location access, then requesting location access is indispensable.
Exact alarm permission
Performing operations at a given time is a pain for Android developers. Each of them makes their own power optimizations, which force each shell to disable them in its own way, and the application must show the instruction. Perhaps we will see an improvement in the work of accurate alarm triggering, since now the SCHEDULE_EXACT_ALARM permission will appear in the system, without which calls to exact alrams in the AlarmManager will throw a SecurityException.
The new permission is not a runtime, which means that the user will have to be sent to the system settings to get it.
Applications should use a new type of alarm if it’s critical functionality. For example, alarms or timers, as well as applications that contain functionality with the requirement to be called at the exact time. It’s possible that Google Play will not allow all applications.
Access Tracking to Clipboard
Now the system monitors access to the clipboard, and when the background application tries to get data from there, you will be notified. Nice innovation that will prevent others from monitoring your data. Do you often “copy-paste” for important data? I sometimes use this for passwords, and it makes me a little scared of what is being done right now.
Restrictions on the use of the Foreground Service
The main change in Android 12 that will confuse Android developers is that the Foreground Service can no longer be launched from the background, except in a few cases. If you have an unsuccessful attempt to start the Service, the application will crash with a ForegroundServiceStartNotAllowedException.
The following cases are exceptional:
- High Priority Push
- As a reaction to broadcasts ACTION_BOOT_COMPLETED, ACTION_LOCKED_BOOT_COMPLETED, or ACTION_MY_PACKAGE_REPLACED
- Application has special permissions or roles
- Application ignores battery optimizations
- Exact alarm
- and some other specific cases
You are encouraged to use the new Expedited Jobs API that has already been added in WorkManager 2.7.0. Android 12 and later will run the corresponding APIs from the JobScheduler, and older Android versions will run the Foreground Service.
versions will run the Foreground Service.
Expedited job allows an application to perform short, important tasks while giving the system better control over access to resources. Expedited Job is between the Foreground Service and a regular job from the JobScheduler in terms of its characteristics:
A short period is a couple of minutes. If your job takes longer, the system may stop the expedited job.
Expedited job is less susceptible to management effects from battery saver systems such as Battery Saver and Doze Mode.
The system starts an expedited job if the system has enough resources for this, and if the number of job already started doesn’t exceed the limit set in the system, and also if there is enough free RAM. These requirements are more stringent than other job types.
Foreground Service notifications will be shown to you with a delay
How often do you see notifications that appear for a couple of seconds and disappear? Maybe you yourself made such notifications with your own code? An experienced developer knows that this is a Foreground Service that gets the job done quickly and therefore the notification shows up and disappears quickly. In Android 12, the notification associated with the Foreground Service will not show for the first 5 seconds. This improvement is UX focused and I hope it will be well received by users. Of course, there are exceptions to the rule, for example, if a notification has action buttons, it will be shown immediately. The developer can explicitly specify that the notification should be shown immediately using the new API in Notification.Builder.setForegroundServiceBehavior ().
Microphone and camera usage indicator
Modern versions of Android and iOS are actively borrowing ideas from each other, and the new system feature is implemented similarly to iOS. When applications use a camera or microphone, an indicator will appear in the status bar, which will not allow doing something in the background. Also, the user at any time can disable access to the camera and microphone for all applications using toggles.
The new functionality of Android 12 will allow users to see the history of all apps’ access to location, microphone and camera. The functionality will be available in the second Beta.
In Android 11, the automatic reset of permissions for unused applications was implemented successfully. If the user doesn’t interact with your application for a very long time (several months), then the system will reset all received permissions and send him to hibernation:
- The application cache will be cleared
- The application will not be able to run job or alert in background
- The application will not receive push notifications, including high-priority FCM
- All restrictions will be removed after the first interaction with your application, but you will need to re-create the job, alarm and notifications that you need. Similar behavior is similar when the user forcibly stops applications in the settings
- You can ask the user to turn off the “Revoke permissions and clear memory” setting in the settings if your application involves working in the background, for example, sending a location between family members.
Limiting the frequency of receiving data from motion sensors
By default, data from various sensors, such as an accelerometer, gyroscope, and others, will arrive at a frequency of 200 Hz or less. You need to declare the new HIGH_SAMPLING_RATE_SENSORS permission in a manifest so that you can receive data as before, but you don’t have to ask the user for it.
Exported declaration for all components in Manifest
For all components in the AndroidManifest, you must now explicitly declare the value “android: exported=true|false”, which is responsible for making the component available to other applications. By default, the value of this attribute is false, but if at least one intent-filter is declared for the component, then the value will change to true. This vulnerability was used by cybercriminals, for example, in this way the Slack authorization was hacked.
If you have targetSdk=S, and some component doesn’t have the exported value declared, then the installation will not complete, and you will see a message in Logcat.
Android Studio 2020.3.1 Arctic Fox contains Android Lint checks so you don’t miss a thing. It’s important that third party libraries that contain the components are updated. Otherwise, you will need to use the Manifest Merger features and set the exported value yourself.
Many interesting changes have happened in Android 12, but I can’t tell you about all the changes in this video, so catch more changes in the quick format:
- ART is now updated regardless of the system
- In the standard Build class, new constants have appeared that allow you to get the chip manufacturer and its model (details).
- New App Standby bucket has appeared — Restrictive. It will be the strictest and most restrictive.
- Bouncy Castle cryptographic algorithm implementations have been removed
- Backup and data recovery have been split between local (over-the-wire) and cloud backups, and the configuration options have been updated.
- The creation of any PendingIntent now explicitly involves specifying whether it is mutable or not
- PiP behavior improvements and new features
- Web intent will now open in the application if the application is approved by this domain. Use Android App Links, or open the system settings of the application and ask the user to add domain to the approved ones
- SameSite cookie support in WebView
- Private Compute Core is an OS-isolated environment for processing user data. For example, Smart Reply, which doesn’t have access to the Internet, and the source code is open. The idea is to process user data on the device without the possibility of leaking it somewhere.
- The ability for apps to automatically update other apps has been added. Previously, only Google Play could do this
The release of Android 12 is scheduled for this fall, but before that there will be several Beta versions that will delight us with the novelties shown on Google I/O. Remember that after the release of Android 12, you will need to adapt your applications for Android 11. I’m waiting in the comments for your impressions of Android 12: what did you like, what did you dislike, and what else do you expect from the green robot update.