The introduction

Google recently released a stable version of Android 11. Android 11 will make it easier for users to enjoy the latest technology without compromising their privacy.

Here’s a timeline of the Android 11 release:

Geturen is deeply involved in the developer world, and has been keeping up with industry trends, taking a deep dive into Android 11 updates. In this article, we’ll talk about the new features of Android 11 in terms of partition storage, package visibility, permissions changes, and new features to help developers quickly and easily adapt to the new Android operating system.

The author | a senior fashion android development engineer

The body of the

Partition storage

Prior to Android 10, content in the external storage area came in two forms: content named by the package name of the application, belonging to a specific application directory, and content stored in the common storage area.

In Android 10, Google introduced partitioned storage for the first time, dividing common areas into collections and establishing a clear division between media files and other documents. After partitioning, applications cannot access files in the external storage area, but can only access media files. If you want to access other documents that contain more detailed data, the application specifically asks the user for access to those documents.

Partitioned storage is mandatory on Android 10 by default. If added in the AndroidManifest requestLegacyExternalStorage = true symbol, is not subject to this restriction. However, after the target API is updated to 30, the system ignores this configuration.

If you have data need to be migrated, can in the heart of the AndroidManifest preserveLegacyExternalStorage attribute set to true, when the users to upgrade to the Android 11 target platform, this configuration will take effect. Specifically, this configuration is valid until the user reinstalls the application.

For Android 11 targeted applications (targetSdkVersion = 30), WRITEEXTENRNALSTORAGE and WRITEMEDIASTORAGE no longer provide any additional access rights.

The core functions of some applications may require access to a large number of files, such as file management, backup, and restore operations. In this case, you need to apply for MANAGEEXTERNALSTORAGE. We can through the use of ACTIONMANAGEALLFILESACCESS_PERMISSION intent for the user guide to a system Settings and let users all files for the application of administrative authority.

Application package visibility

Before the Android 11, we can through the PackageManager. GetInstalledPackages (0) for all other application information such as the package name.

Android 11 has made some changes to the visibility of application packages to increase security and better protect users’ privacy.

If we use getPackageInfo(” another. App “,0) to obtain other application package information when targetSdkVersion is 30, NameNotFoundException will occur.

We can add it in AndroidMainfest to suit specific usage scenarios :(this configuration is equivalent to adding a whitelist of apps)

  1. Given the package name you want to obtain:

2. Query a set of applications with a specific purpose or interact with them:

  1. For some special applications, you want to get all package name information:

Permission to change

In Android 11, the system offers more options for authorizing users’ private data, and apps restrict background access to locations.

Users can grant one-time, temporary access to the camera, location information, and microphone data types.

This restriction works on Android 11, as shown below:

The effective period of this one-time permission refers to:

  1. Application Activity visible during
  2. A short time after the application goes into the background
  3. The life of the front desk service
  4. After a user revokes a single authorization, the application process exits and needs to be re-authorized

Location permissions

Prior to Android10, we could apply for front and back location permissions through ACCESSCOARRSELOCATION or ACCESSFINELOCATION(exact location) configuration.

Android 11 divides location permissions into foreground and background permissions. The above mentioned is mainly the foreground authority, authorization mode has not changed. To apply for background permissions, in addition to adding additional ACCESSBACKGROUNDLOCATION permissions to the manifest file, the application also needs to actively direct the user to the specified page for authorization.

New features

Added the application exit reason function

Prior to Android 11, it was difficult to understand why an app was quitting and what its status was. Android now 11 introduces methods: ActivityManager getHistoricalProcessExitReasons (), allows us to clearly understand the application exit.

Variable refresh rate

Apps and games can now set the preferred frame rate for their Windows. Most Android devices update their screens at a refresh rate of 60Hz, but some devices support multiple refresh rates, such as 90Hz and 60Hz, and can be switched at run time. On these devices, the system selects the best refresh rate for the application based on the preferred frame rate.

conclusion

Android 11 has introduced some new features such as partition storage, application package visibility, and permission changes. While Google strives to make it easier for users to use the Android system, it also hopes that the privacy and security of users’ data will be protected to the maximum extent.

Twitter aims to provide developers with a good SDK. In order to improve the stability and compatibility of the SDK, Qitai has also carried out in-depth research on the new features of Android 11, and will soon launch a new adaptation solution for its products to meet the different use scenarios of developers. In addition, we hope to communicate with more developers to explore new Android technologies, improve user experience, and build a better Android development ecosystem together.