4

Features and APIs Overview  |  Android 13 Developer Preview  |  Android Develope...

 2 years ago
source link: https://developer.android.com/about/versions/13/features
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Features and APIs Overview

Android 13 introduces great new features and APIs for developers. The sections below help you learn about features for your apps and get started with the related APIs.

For a detailed list of new, modified, and removed APIs, read the API diff report. For details on new APIs visit the Android API reference — new APIs are highlighted for visibility. Also, to learn about areas where platform changes may affect your apps, be sure to check out Android 13 behavior changes for apps that target Android 13 and for all apps.

User experience

Themed app icons

User opting into themed app iconsFigure 1: Opting into themed app icons on Android 13

Starting with Android 13, users can opt into themed app icons. With this feature, app icons in supported Android launchers are tinted to inherit the coloring of the user’s chosen wallpaper and other themes.

To support this feature, your app must provide a monochromatic app icon and point to it from the <adaptive-icon> element in the manifest. If a user has enabled the Themed icons toggle on their device, the system uses the coloring of the user’s chosen wallpaper and theme to determine the tint color, which it then applies to the monochromatic app icon.

Specifications

Your monochromatic app icon should meet the following specifications:

  • It should be a VectorDrawable.
  • We recommend that the logo fits within a 36 x 36 dp area inside a 90 x 90 dp container. If the logo needs to be larger, it can be a maximum of 60 x 60 dp.
  • We recommend flat logos; if your logo is three-dimensional you can use the alpha gradient.

Most apps can reuse the vector drawable used for notifications.

The following example shows a monochromatic app icon for the Google app, with dotted lines representing the boundaries between the logo and container areas. These boundaries are presented here only for illustrative purposes and are not sized to scale.

Monochrome design specifications for a themed app icon: the icon on the             left has dotted lines representing the measurements, with the outside             dotted line labeled as '1' and representing the icon container,             and the internal dotted line labeled '2' and representing the logo             area; the icon on the right is how this actually looks without the             added dotted lines

Figure 2: Themed app icon measurements

1 Container area (90 x 90 dp).

2 Logo area (36 x 36 dp recommended, 60 x 60 dp maximum).

Implement a themed app icon

Add the monochrome android:drawable attribute to the <adaptive-icon> element. For example, in res/mipmap-anydpi-v26/ic_launcher.xml:

<adaptive-icon >
    <background android:drawable="..." />
    <foreground android:drawable="..." />
    <monochrome android:drawable="@drawable/myicon" />
</adaptive-icon>

In your manifest file, define the icon using android:icon:

<application
    …
    android:icon="@mipmap/ic_launcher"
    …>
</application>
Note: If android:roundIcon and android:icon are both in your manifest, you must either remove the reference to android:roundIcon or supply the monochrome icon in the drawable defined by the android:roundIcon attribute.

Quick Settings placement API

Quick Settings in the notification shade is a convenient way for users to change settings or take quick actions without leaving the context of an app. For apps that provide custom tiles, we’re making it easier for users to discover and add your tiles to Quick Settings. Using a new tile placement API, your app can now prompt the user to directly add your custom tile to the set of active Quick Settings tiles. A new system dialog lets the user add the tile in one step, without leaving your app, rather than having to go to Quick Settings to add the tile.

A dialog asking the user whether they want to add a tile to their           Quick Settings.

Better support for multilingual users

Android 13 introduces several features to improve app experiences for multilingual users, which the following sections describe:

Per-app language preferences

In many cases, multilingual users set their system language to one language—such as English—but they want to select other languages for specific apps, such as Dutch, Chinese, or Hindi. To help apps provide a better experience for these users, Android 13 introduces APIs that let apps set a different language at runtime to display in their user interface.

Apps that use custom in-app language pickers can use the new APIs to reduce the amount of boilerplate code that's required to display an in-app language picker. To support previous versions of the Android platform, we'll be adding similar APIs in upcoming versions of our Jetpack libraries.

Apps that do not support multiple languages are not impacted by these changes.

See the page on Per-app language preferences for more details.

Unicode library updates

Android 13 adds the latest improvements, fixes, and changes that are included in Unicode ICU 70, Unicode CLDR 40, and Unicode 14.0.

Here are a couple notable changes:

  • English (Canada) en‑CA and English (Republic of the Philippines) en‑PH both use English (United States) en translation resources when there are no translation resources available instead of English (United Kingdom) en‑GB.
  • The many plural category has been introduced for Spanish es, Italian it, Portuguese pt, and Portuguese (Portugal) pt‑PT. Similar to French introduced in CLDR v38, this is used for large numbers.

Faster hyphenation

Hyphenation makes wrapped text easier to read and helps make your UI more adaptive. In Android 13, we’ve optimized hyphenation performance by as much as 200% so you can now enable it in your TextView with almost no impact on rendering performance. To enable faster hyphenation, use the new fullFast or normalFast frequencies in setHyphenationFrequency().

Privacy and security

Photo picker

Android 13 includes a new photo picker experience. When your app launches the photo picker, users select specific images and videos to share with your app, such as profile pictures, instead of giving your app access to view the entire media library.

The photo picker provides enhanced privacy for users because your app doesn’t need to declare any runtime permissions. In addition, the photo picker provides a built-in, standardized UI for apps, which creates a more consistent user experience.

Note: The photo picker is now the recommended way to access the user’s photos and videos.

New runtime permission for nearby Wi-Fi devices

Android 13 introduces a new runtime permission in the NEARBY_DEVICES permission group for apps that manage a device's connections to nearby access points over Wi-Fi. These apps must declare the new permission, NEARBY_WIFI_DEVICES, when they call several different Wi-Fi APIs. In addition, as long as apps don't derive physical location from the Wi-Fi APIs, they don't need to declare the ACCESS_FINE_LOCATION permission when they target Android 13 or higher.

Learn more about the nearby Wi-Fi devices permission.

Graphics

Programmable shaders

An AGSL animated shader, adapted from this GLSL Shader.

Android 13 adds support for programmable RuntimeShader objects, with behavior defined using the Android Graphics Shading Language (AGSL). AGSL shares much of its syntax with GLSL, but works within the Android rendering engine to customize painting within Android's canvas as well as filtering of View content. Android internally uses these shaders to implement ripple effects, blur, and stretch overscroll, and Android 13 enables you to create similar advanced effects for your app.

Core functionality

OpenJDK 11 updates

Android 13 starts the work of refreshing Android's core libraries to align with the OpenJDK 11 LTS release with both library updates and Java 11 language support for application and platform developers. The core library changes introduced in Android 13 will also be available to Android 12 devices through a Google Play system update to the ART Mainline Module.

Android 13 includes the following changes to core libraries:

  • Support for the var keyword for local variables and as parameters lambdas.
  • New methods in the String class:

    • isBlank()
    • lines()
    • repeat()
    • strip()
    • stripLeading()
    • stripTrailing()
  • Support for Collection.toArray(IntFunction) to make it easier to adapt a collection to an array.

  • Support for ifPresentOrElse(), isEmpty(), orElseThrow(), and stream() in java.util classes Optional, OptionalDouble, OptionalInt, and OptionalLong.

  • Extended support for SocketOptions including re-use of sockets.

  • NullReader, NullWriter, InputStream, OutputStream, and transferTo() Reader functionality which transfer read characters to a Writer.

  • Added functionality for URL encoding and decoding using Charsets.

  • Charset functionality for FileReader, FileWriter, PrintStream, and PrintWriter.

  • New transferTo(), readNBytes(), readAllBytes(), and writeBytes() functions for ByteArrayInput or OutputStream and Input or OutputStream.

  • Runtime and compiler support for java.lang.invoke.VarHandle.

  • Updates java.util.concurrent to OpenJDK 11 API using VarHandle internally.

Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK