The introduction
Google has released the first developer preview of its new operating system Android 12. ** The final version of Android 12 is expected to launch in the second half of this year, according to Google. ** The main purpose of this release preview is to help developers understand the new changes in Android 12 ahead of time and prepare for future adaptation.
As an important partner of developers for many years, Getui has been closely following and following the development trend of the industry. Following the release of the first developer preview of Android12, twitter quickly conducted research on updates to the new system. This article takes a look at some of the new features and features in the Android 12 preview, hoping to help developers get a quick understanding of the new system.
Android 12 Behavior change: For all apps
I. Upgrade of user experience and improvement of immersive gesture navigation
Since Android 10, The Android system has supported gesture navigation, aiming to bring users a new immersive experience. On previous versions of the operating system, users activated Android’s Immersion mode, and by default required gestures to slide in from the side of the screen, exit immersion mode, and return to the previous screen. The first developer preview of Android 12, released recently, simplifies the gesture navigation mode: Instead of swiping twice, users can swipe once to exit full-screen immersion mode and return to the previous screen, making it more efficient and convenient.
2. Enhanced privacy/security protection
1. MAC address permission restriction
To further protect user privacy and data security, Android 11 has introduced features such as single authorization, automatic permission reset, and partitioned storage. Android 12 goes a step further and restricts access to the device’s MAC address by all non-system applications, regardless of the target API level.
The relevant API returns either a null value or a placeholder value, depending on the target SDK version of the application:
Jie target = 12, return null
Target <12, return 02:00:00.00:00:00:00
2. Untrusted touches are blocked
To protect system security and better user experience, Android 12 will block certain Windows from touching.
Such as:
The Windows that apply for the SYSTEM_ALERT_WINDOW privilege
➁ Toast messages
3. Do not close the system dialog box
ACTION_CLOSE_SYSTEM_DIALOGS Intent is deprecated in Android 12.
Jie target = 12, will throw SecurityException exception
If target < 12, the intent will not be executed. If target < 12, the intent will default to logcat.
E ActivityTaskManager Permission Denial: \
android.intent.action.CLOSE_SYSTEM_DIALOGS broadcast from \
com.package.name requires android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS, \
dropping broadcast.
Android 12 Behavior change: For Target = 12 apps
Custom notification bar
The Android 12 Developer Preview has made changes to the notification bar. Left: Android 12 developer preview, right: Android 11
Previously, developers were able to customize the layout and style of the entire notification area, which led to compatibility issues across devices and user browsing issues.
Android 12 has changed the look of fully custom notifications. For applications with target = 12, the same template is used for displaying messages in the notification bar. The above application name display and collapse buttons are the same and fixed, and the following areas for collapse and expand state display are customizable:
Folding and expanding styles:
Folding state
A state of
If there is a custom notification. Style in APP, Or use setCustomContentView(RemoteViews) in Notification.Builder. SetCustomBigContentView (RemoteViews) and setCustomHeadsUpContentView (RemoteViews) method, may be affected by this.
Privacy/Security
SameSite cookie behavior in WebView
The WebView component for Android is based on Chromium to improve security and privacy, and Chromium made changes to the way third-party cookies are handled last year that have been rolled out to many Chrome users. Starting with Android 12, these changes will apply to WebView.
The SameSitecookie property controls whether it can be sent with any request or only with requests from the same site. The basic version of WebView in Android 12 (version 89.0.4385.0) improves the default handling of third-party cookies and will help prevent accidental cross-site sharing.
The ADB backup limit
Android 12 limits the default behavior of the adb backup command line, which is used to backup and restore data. Developers who rely on adb backup for application data can set the Android :debuggable to true in the manifest file.
The component needs to add a exported configuration
If the activity, service, or broadcast uses intent filters when target=12, you need to declare the Android :exported attribute. If not configured, it will not install on Android 12 devices and logcat will print error logs:
Targeting S+ (version 10000 and above) requires that an explicit value for \
android:exported be defined when intent filters are present
Pending Intents must declare intents
FLAG_MUTABLE flag PendingIntent intent.FLAG_IMMUTABLE Flag PendingIntent.FLAG_IMMUTABLE flag PendingIntent. Otherwise, the system throws an IllegalArgumentException.
performance
Foreground service startup restrictions
Applications targeting Android 12 cannot start foreground services while running in the background. Consider using WorkManager to perform tasks while the application is running in the background.
ForegroundService notification delay
After foreground service is started, startForeground() must be called to display foreground notification. If startForeground() is not called within 5s, the system will stop the service and declare the application as ANR.
In Android 12, the time limit was changed from 5s to 10s. As a result, there will be more processing time for some apps.
Notify the jump
StartActivity () cannot be called for notifications created in services or Broadcast Receivers!!
Logcat will print:
Indirect notification activity start (trampoline) from PACKAGE_NAME, \this should be avoided for performance reasons.
conclusion
Above, a look at some of the key updates in the first Developer preview of Android 12.
In addition to the above, the Android 12 preview has a number of interesting updates for video, audio, and image handling. For example, adding tactile coupled audio effects through the vibration motor of the phone can help improve the player experience of game apps. Media compatible transcoding is introduced, which can efficiently transcode files to AVC format even for applications that do not support HEVC. AV1 image File Format (AVIF) support has also been introduced, allowing developers to reap higher image quality than JPEG images with the same file size… Interested developers can check out the Android 12 website for more details.
Developer. The android. Google. Cn/about/versi…
In the future, While continuing to polish developer services and SDK products, Individual Push will closely follow up relevant trends in the field of mobile development, and provide effective suggestions for developers to upgrade product functions and iterate service experience.
We also welcome more developers to communicate and explore new technologies of Android and mobile development with us, and jointly build a better Android development ecosystem.
* The image is from Android official website