New features of each Android version

A:

We can see the Api version for the Android version



2: the Android 6.0

As promised, Google I/O 2015 was held on May 28, 2015. At the event, Android 6.0, code-named “Marshmallow,” was launched.

API level for Android 6.0:23

New features:

1. Runtime permissions (primary)

This release introduces a new permission mode that allows users to directly manage application permissions at run time.

For applications targeting Android 6.0 (API level 23) or higher, be sure to check and request permissions at run time. To determine whether your application has been granted permissions, call the new checkSelfPermission() method. To requestPermissions, call the new requestPermissions() method. Even if your application is not targeted for Android 6.0 (API level 23), you should test your application under the new permission mode.

2. Cancel the support for the Apache HTTP client

Android 6.0 removed support for the Apache HTTP client.

If your application uses this client and is targeting Android 2.3 (API level 9) or higher, use the HttpURLConnection class instead. This API is more efficient because it reduces network usage and minimizes power consumption through transparent compression and response caching. To continue using the Apache HTTP API, you must first declare the following compile-time dependencies in the build.gradle file:

Android {useLibrary 'org.apache.http.legacy'// Use apache libraries}

Android 7.0 is Google’s smartphone operating system, officially code-named “Nougat”. Officially unveiled at Google I/O Developer Conference on May 18-20, 2016 (EST), Android 7.0 includes changes in system behavior designed to extend the battery life of devices and reduce RAM usage. These changes may affect how your application accesses system resources and how your application interacts with other applications through specific implicit Intents. Low Power Mode Android 6.0 introduces a low power mode, which delays CPU and network activity, thereby extending battery life, when the user’s device is not plugged in, is stationary and the screen is off. Android 7.0 further enhances the low-power mode by applying some of the CPU and network limitations when the device is not plugged in and the screen is off, but not necessarily stationary, such as when the user is out with the handheld device in his or her pocket. To improve the security of private files, access to the private directory of applications for Android 7.0 or higher is restricted (0700). This setting prevents metadata leaks about private files, such as their size or existence. This permission change has multiple side effects passing the file:// URI outside the network domain of the package may leave an unreachable path for the receiver. Therefore, an attempt to pass a file:// URI triggers a FileUriExposedException. The recommended way to share private file content is to use FileProvider. Access system albums before Android7.0

File file = new File(Environment.getExternalStorageDirectory(), "/temp/" + System.currentTimeMillis() + ".jpg"); if (! file.getParentFile().exists()) file.getParentFile().mkdirs(); Uri imageUri = Uri.fromFile(file); Intent intent = new Intent(); // Set the Action to take a photo. Intent.setaction (mediastore.action_image_capture); // Save the taken photo to the specified URI Intent.putextra (mediastore. EXTRA_OUTPUT, imageUri); // Save the taken photo to the specified URI Intent.putextra (MediaStore. startActivityForResult(intent, 1);

After 7.0 to access photo album will be submitted to the following error: android. OS. FileUriExposedException: file:///storage/emulated/0/temp/1627010812423.jpg exposed beyond app through ClipData. Item. GetUri () on the Android7.0 system, The Android framework enforces the StrictMode API policy that prohibits exposing the file:// URI outside your application. If an Intent containing the file:// URI type leaves your application, the application fails and a FileUriExposedException occurs, such as calling the system camera to take a photo, or cropping a photo. Solution: Step 1: Register the provider in the androidManifest.xml

< the provider of the android: name = "androidx. Core. Content. FileProvider" / / not androidx android:name="android.support.v4.content.FileProvider" Android: authorities = "com. Ruan. Mygitignore. Fileprovider" / / package name. Fileprovider android: exported = "false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_path" />

Parameter description:

  • Name: Is fixed
  • Android: Authorities recommend writing your application package name + “.fileProvider “. You don’t have to write fileProvider, you can write whatever you want. As long as use with behind FileProvider. GetUriForFile () the second parameter of this method for authority; (URI URI = FileProvider. GetUriForFile (context, “com. Ruan. Mygitignore. FileProvider”, file);)
  • Android: grantUriPermissions fixed true, said uri access authorization;
  • Android :exported fixed false, I tried to write true to report a security exception.
  • Android: Resource refers to the resource file in the path of our app to share the file.

Step 2: Create an XML folder with the same name as android: Resource = “@xml/file_paths”

<? The XML version = "1.0" encoding = "utf-8"? > <paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path name="Camera" path="" /> </paths>
  • A resource file named “file_paths” (as long as it matches the resource referenced by the provider registered in the manifest in step 1).
  • In this code, path= “” has a special meaning. It refers to the root directory, which means that you can access any file in the root directory or subdirectories to other applications. If you set path=” pictures “, It represents the root directory of pictures directory (eg: / storage/emulated / 0 / pictures), then you visit pictures beyond the range of the file is not a directory.
  • Files-path represents the root directory: context.getFilesdir ()
  • External – path represents the root directory of the: Environment. External.getexternalstoragedirectory ()
  • Cache-path indicates the root directory: getCacheDir()

Step 3: Use FlieProvider

// private void getPhoto(Context Context) {// Select a photo from a photo album, select a photo from a photo */ private void getPhoto(Context Context) { Fixed name before 7.0 will replace the File File = new File (Environment. External.getexternalstoragedirectory (), "/temp/" + System.currentTimeMillis() + ".jpg"); if (! file.getParentFile().exists()) file.getParentFile().mkdirs(); / / create a content type Uri Uri through FileProvider imageUri = FileProvider. GetUriForFile (context, "com.ruan.mygitignore.fileprovider", file); Intent intent = new Intent(); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // Set the Action to take a photo. Intent.setaction (mediastore.action_image_capture); // Save the taken photo to the specified URI Intent.putextra (mediastore. EXTRA_OUTPUT, imageUri); // Save the taken photo to the specified URI Intent.putextra (MediaStore. // Start an Activity with a return value. PHOTO_REQUEST_GALLERY startActivityForResult(Intent, 1); System.out.println(imageUri); } / / results System. Out: the content: / / com. Ruan. Mygitignore. Fileprovider/Camera/temp / 1627018704311 JPG

The simplest example is to turn on the camera:

File file = new File(Environment.getExternalStorageDirectory(), "/temp/" + System.currentTimeMillis() + ".jpg"); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (Build.VERSION.SDK_INT >= 24) { intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); / / 24 above use FileProvider intent. PutExtra (MediaStore. EXTRA_OUTPUT FileProvider. GetUriForFile (FiveTeenActivity. This, "com.ruan.mygitignore.fileprovider", file)); }else{//24 Following Intent.putextra (mediastore.extra_output, uri.fromfile (file)); } startActivityForResult(intent, 1);

Change the Uri whose scheme type is file to create a CONTENT Uri with the FileProvider. Intent.addflags (Intent.flag_GRant_READ_URI_permission); To apply temporary authorization to the target for the file represented by the Uri.

August 22, 2017, Google officially released Android 8.0 official version, its official name: Android Oreo (Oreo). Google released Android 8.1 on December 5, 2017. Notification Channels are application-defined categories of notifications. With Channels, you can give users fine-grained control over different types of notifications. Instead of managing all notifications in your app, you can block or change the behavior of each channel individually. Steps to create a notification channel:

  • Create a NotificationChannel object and set the notification ID that is unique within the application.
  • Configure the properties of the notification channel, such as the prompt sound.
  • Register the notification channel object in NotificationManager. 2. Picture-in-picture mode — PIP Android O now supports picture-in-picture mode for Activity. PIP is a multi-window display mode, mostly used for video playback. This is not the same as ordinary painting in split screen mode. To wake up the feature, just click the Home button, and if you want to end the mode, you can slide down the small window to terminate. About lifecycle The PIP pattern does not change the lifecycle of an Activity. Only the Activity that the user has recently interacted with is in the active state at a given time. This Activity will be considered a top-level Activity. All other activities, while visible, are paused. When an Activity is in PIP mode, it is actually in the paused state, but its contents continue to be displayed. API changes Add a PictureInPictureArgs object in Android to indicate properties of your Activity in PIP mode, such as aspect ratio. Android O has also added the following methods to support PIP.
Activity. EnterPictureInPictureMode (PictureInPictureArgs args) : will the Activity under PIP mode. Activity. SetPictureInPictureArgs () : used to update the Activity in PIP mode Settings. If the Activity is in PIP mode, the changed properties take effect immediately.

Android 9.0 is a mobile operating system developed by Google, code-named “Pie”, and officially released on August 7, 2018. Android 9 adds platform support for the IEEE 802.11 MC Wi-Fi protocol, also known as Wi-Fi round-trip-time (RTT), allowing your applications to take advantage of indoor location capabilities.

On hardware supported devices running Android 9, applications can use the RTT API to measure the distance to a nearby RTT-enabled Wi-Fi access point (AP). The Location service and Wi-Fi scanning must be enabled on the device (under Settings > Location), and your application must have the ACCESS_FINE_LOCATION permission.

Devices do not need to be connected to an access point to use RTT. To protect privacy, only the phone can determine the distance from the access point; The access point does not have this information.

If your device measures distances to three or more access points, you can use a multipoint location algorithm to estimate the device location that best matches those measurements. The results are usually accurate to one or two metres.



With this precision, you can create new experiences such as in-building navigation, fine-location-based services such as unambiguous voice controls (for example, “Turn on this light”), and location-based information such as “Is there a special deal on this product?” ).

2. Display gap support

Android 9 supports the latest full screen, which includes gaps in the screen to make room for the camera and speakers. The DisplayCutout class determines the position and shape of non-functional areas where content should not be displayed. To determine if and where these screen gap areas exist, use the getDisplayCutout() function.



New window layout attribute layoutInDisplayCutoutMode lets your application for the equipment layout screen gap around the content. You can set this property to one of the following values:

LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT

LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES

LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER

You can simulate the screen gap on any device or emulator running Android 9 as follows:

Enable developer options. On the Developer Options screen, scroll down to the Drawing section and select Simulate A Display with a Cutout. Select the size of the screen notch. Note: We recommend that you test the display of content around the screen gap by using a device or emulator running Android 9. 3. Foreground service If your application is on Android 9 or later and uses foreground services, you must request the FOREGROUND_SERVICE permission. This is a common permission, so the system automatically grants it to the application that requests it.

If an application targeting Android 9 or later tries to create a foreground service and does not request the FOREGROUND_SERVICE, the system throws a SecurityException.

public class FloatPasswordWindowService extends Service { @Override public void onCreate() { super.onCreate(); } @Nullable @Override public IBinder onBind(Intent intent) { LogUtils.d("FloatWindowService:onBind"); return null; } @override public int onStartCommand(Intent Intent, int flags, int startId) { "OnStartCommand ()"); // Parameter 1: unique notification identifier; Parameter two: Notification message. startForeground(110, notification); } @override public void onDestroy() {log.d (TAG, "onDestroy()"); stopForeground(true); // Stop the foreground service -- argument: whether to remove the previous notification super.onDestroy(); }}

9.0 requires that creating a foreground service requires requesting FOREGROUND_SERVICE permission, otherwise the system will raise SecurityException.

Intent intentService = new Intent(this, MyService.class); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { startForegroundService(intentService); } else {startService(intentService); }

PS: table forget to add the FOREGROUND_SERVICE permission in androidmanifest.xml

Don't forget to < / / 9.0 the front desk service authority USES - permission android: name = "android. Permission. FOREGROUND_SERVICE" / >

In 9.0, do not start an Activity directly from a non-activity environment (such as Service, Application), otherwise it will crash and report an error. This is usually the case when you click a push message to redirect to the page. The solution is to add the FLAG_ACTIVITY_NEW_TASK flag to the Intent

Intent intent = new Intent(this, TestActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

5. The Http request Please see articles before https://segmentfault.com/a/11… Apache HTTP client deprecated With Android 6.0, support for the Apache HTTP client was removed. Starting with Android 9.0, the library has been removed from Bootclasspath by default. However, some SDKS are still in use, such as the QQ sharing error I saw. So to continue using Apache HTTP, add the following to your application’s Androidmanifest.xml file:

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:networkSecurityConfig="@xml/network_security_config" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.MyGitignore"> <uses-library android:name="org.apache.http.legacy" Android :required="false"/>// use <application/>

Android 10 includes a number of upgrades, including gesture navigation, notification bar management, global dark mode, and more. Notification management has added “priority”, “silent” and “adaptive notification” features, and a dark themed background. Changes to user storage Permissions Android Q provides an “isolated storage sandbox” (for example, / sdCard) for each application in external storage devices. No other application can directly access your application’s sandbox files. Because files are private to your application, you no longer need any permissions to access and save your files on external storage devices. This change makes it easier for you to keep user files private and helps reduce the number of permissions your application requires. Google’s recommended that the address of a storage file application within the sandbox for Context. GetExternalFilesDir folder (). You want to store an image, for example, should be put in Context. The getExternalFilesDir (Environment. DIRECTORY_PICTURES). 2. Changes in user location permissions In order to give users better control over the application’s access permission to location information, Android Q introduces a new location permission ACCESS_BACKGROUND_LOCATION.

Unlike the existing ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permissions, the new permissions only affect the application’s access to location information while it is running in the background. An application is considered to be running in the background unless one of its activities is visible or the application is running a foreground service. Just like iOS, the ACCESS_BACKGROUND_LOCATION permission is added to Q. If an application needs to obtain the user’s location in the background (such as Didi), it needs to apply for the ACCESS_BACKGROUND_LOCATION permission dynamically.

Of course, if not, the app doesn’t need to change anything, and Google will do it differently based on the app’s targetSDK: TargetSDK <= P If the application requests ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION, the Q device will automatically apply ACCESS_BACKGROUND_LOCATION for you.

3. The unique IDENTIFIER of the device starts from Android Q. The application must have the READ_PRIVILEGED_PHONE_STATE signature permission to access the non-reset identifier (including the IMEI and serial number) of the device. If your application does not have this permission, but you still try to query for information about the identifier, a null value or an error will be returned. Note that the original READ_PHONE_STATE permission can no longer obtain IMEI and sequence. If you want to get the ID of the device on the Q device by using the following code

((TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId()

The above code returns a null value (targetSDK<=P) or an error (targetSDK==Q). The official READ_PRIVILEGED_PHONE_STATE privilege is only provided to the system app, so this method does not work. Google officially gives the best practice of unique ID for devices, but the ID given in this method is variable and can be solved according to specific needs. In this paper, we give an invariant and basically non-repetitive UUID method:

public static String getUUID() { String serial = null; String m_szDevIDShort = "35" + Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + Build.USER.length() % 10; / / 13 try {the if (Build) VERSION) SDK_INT > = Build. VERSION_CODES. O) {. Serial = android OS. Build. GetSerial (); } else { serial = Build.SERIAL; } //API>=9 Return new UUID(m_szdevidshort-hashcode (), serial.hashcode ()).tostring (); //API>=9 return new UUID(m_szdevidshort-hashCode (), serial.hashCode()).tostring (); } catch (Exception Exception) {//serial needs an initialization serial = "serial"; Return new UUID(m_szdevidshort-hashCode (), serial.hashcode ()).tostring (); }

Android 11 will be released on September 9, 2020. The system mainly enhanced chat bubble, security and privacy protection, power menu, can better support waterfall screen, foldable screen, dual screen and Vulkan extension. New features 1. SMS updates improved the first is chat bubbles. Similar to the Messenger app That Facebook has offered on Android for years, Android 11 has optimized messaging features for a friendlier interaction. Also, to ensure that users receive each other’s messages as quickly as possible, Android 11 has introduced a dedicated conversation section in Notification Shade that will provide instant access to any conversation a user is having. This update will help SMS messages stand out from other notifications. 2. Phone number-related permissions Android 11 changes the phone number-related permissions that your app uses when reading phone numbers.

There are actually two apis: the getLine1Number() method in the TelecomManager class and the getMsisdn() method in the TelecomManager class

When using these two apis, the original READ_PHONE_STATE permission does not work. You need the READ_PHONE_NUMBERS permission. 3. APK signature scheme v2 is required. Applications that target Android 11 (API level 30) and currently only use APK signature scheme V1 must also be signed using APK signature scheme V2 or later. Users will not be able to install or update applications that are signed only by the APK signature scheme V1 on devices running Android 11.

If your targetSdkVersion is changed to 30, then you must add the V2 signature. Otherwise, you cannot install and update. Android 12 rediscovered a feature codenamed Columbus and optimized the triggering problem, with new gestures requiring a harder tap on the back. The new double-tap backside gesture can take a screen shot, summon Google Assistant, open the notification bar, control media play or open a list of recent apps. 1. AVIF image support

  1. To give you higher image quality and more efficient compression, Android 12 introduces platform support for the AV1 Image File format (AVIF). AVIF is a container format for images and image sequences encoded using AV1. Like other modern image formats, AVIF makes use of intra – frame encoded content in video compression. This can significantly improve image quality for the same file size compared to older image formats such as JPEG. Foreground services are an important way for applications to manage some types of user-facing tasks, but if overused, they can affect performance or even cause application outages. In order to ensure a better user experience, we will prevent foreground services from starting from the background for applications targeting the new platform. To make the transition from this mode easier, we’ve introduced a new expeditors job in JobScheduler that gets a high process priority, network access, and can run immediately without regard to power saving or power saving. For backward compatibility, we have also built in expedits in the latest version of the Jetpack WorkManager library. In addition, to reduce user attention, we now delay the display of certain foreground service notifications for up to 10 seconds. This gives short tasks a chance to complete before the notification is displayed

END: Your fearlessness comes from ignorance.