Android 13 Developer Preview: New Features and APIs

Reading Time: 24  min
Android 13 Developer Preview: New Features and APIs

The Developer Preview for Android 13 has been released, and Google has come up with some long-awaited modifications and introductions. The preview was released with a set of concentrated features, several modifications to the user interface, and numerous behavioral and platform changes. The Beta version is now available, and updates are soon to be added. While it is still in preview, there are several new platform APIs and features that might be interesting for you to know as an Android developer. Read on to find out how these additions and modifications can help ease your development journey. Understand the possibilities they create for you and what considerations you should have while working with them.

Android 13 has several new features and APIs that can give you more possibilities to enhance mobile user experience. Major areas of improvement are developer productivity, graphics and media, privacy and security, user experience, and core functionality. Let us dig deeper into the vibrant new features and APIs of the new release.

Developer productivity

Several features were added to support developers so they can create a better experience for Android users. Here is a list of a few that can help enhance your productivity:

Themed app icon: Let us start where your users begin the clicks when they pick-up a smartphone. Users want easy-to-find icons so they can reach their favourite applications fast. On the top of that, many want a pleasing interface with icons not just directing them but also connecting with them deeper, for which they use themes. Let us now understand the themed app icons that are introduced by Google in the latest release of Android 13. With this feature, app icons in supported Android launchers are tinted to inherit the coloring of the user’s chosen wallpaper and other themes.

Let’s see how your themed icon set would look on the screen of the user:

Themed app iconIcons tinted to inherit the coloring

Without themed icon With themed icon

Before you implement the themed set, your app must have a consideration for the following specifications for the monochromatic app icon:

  • It should be a VectorDrawable
  • It is recommended that the logo fits within a 44 x 44 dp area inside a 108 x 108 dp container. Larger logos can take a maximum area of 72 x 72 dp
  • Flat logos are recommended; For three-dimensional logos, use the alpha gradient
  • You might point out the monochrome attribute to the same VectorDrawable used by the foreground layer of your adaptive app icon or reuse the vector drawable used for notifications

Please note that the themed app icon feature will not work in the following scenarios:

  • If the user hasn’t enabled themed app icons
  • If your app doesn’t provide a monochromatic app icon
  • If the launcher doesn’t support themed app icons

Also, 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 setting placement APIs

Quick setting pane is another area that is most explored by users as they scan it to find ways to control modes and settings of their devices. The quick setting pane appears when a user swipes down the screen and shows default functionalities like on/off for flight and mobile data. Android 13 introduces a new placement API that allows developers to create a custom tile of your app for quick actions without leaving the context of an app. A new system dialog lets a user add a tile with a single step without leaving the current app to access Quick Settings.

You can create your own tile component by extending the available ‘TileService’ class and request ‘StatusBarManager’ to add your tile by providing icon and name of your tile.

Quick setting placement APIs

Working with Languages

With Android 13, Google has modified the language preference options, updated the Unicode library, enabled text conversions, and improved Japanese text-wrapping. Let’s see how these settings work:

Pre-app language preferences: Among settings are also language preferences that play a role in shaping user experience. In many cases, multilingual users set a standard system language such as English. But at times, they might want to access different languages like Dutch, Hindi, or Spanish. Android 13 now allows them to set a language at runtime.

This can be done in two ways:

1. System Settings – This is centralized location from where a user can select language preference for an app. To enroll your app for this change, define ‘android:localConfig’ attribute in your app’s manifest

<locale-config xmlns:android="http://schemas.android.com/apk/res/android"> 

   <locale android:name="fr"/>
   <locale android:name="en"/>
</locale-config> 

2. APIs for setting up different language runtime

For backward compatibility, APIs are available in AndroidX starting with Appcompat 1.6.0-alpha01. Use the ‘setApplicationLocales()’ method in the same library version or above.

Implement using AndroidX

val appLocale: LocaleListCompat = LocaleListCompat.forLanguageTags("xx-YY") 
// Call this on the main thread as it may require Activity.restart() 
AppCompatDelegate.setApplicationLocales(appLocale)

Implement using the Android framework APIs

To set user’s selected language

mContext.getSystemService(LocaleManager.class).setApplicationLocales(newLocaleList(Locale.forLanguageTag("xx-YY"))); 

To get a user’s current proffered language

LocaleList currentAppLocales = mContext.getSystemService(LocaleManager.class).getApplicationLocales(); 

Unicode library updates: Android 13 comes with the latest improvements, fixes, and changes in Unicode ICU 70, Unicode CLDR 40, and Unicode 14.0. Some of these notable changes are:

  • English (Canada) enCA and English (Republic of the Philippines) enPH both use English (United States) en translation resources when there are no translation resources available instead of English (United Kingdom) enGB.
  • A plural category was introduced for Spanish es, Italian it, Portuguese pt, and Portuguese (Portugal) ptPT. Similar to French in CLDR v38, this one is used for large numbers.

Text Conversion APIs: People who speak languages like Japanese and Chinese use phonetic lettering input methods, which often slow down searching and features like auto- completion. In Android 13, apps can call the new text conversion API so users can find what they’re looking for faster and easier. Previously, for example, searching required a Japanese user to do these steps:

  • Input Hiragana as the phonetic pronunciation of their search term (such as a place or an app name)
  • Use the keyboard to convert the Hiragana characters to Kanji
  • Re-search using the Kanji characters
  • Finally get their search results

With the new text conversion API, Japanese users can type in Hiragana and immediately see Kanji search results live, skipping steps 2 and 3.

Improved Japanese text wrapping: TextViews can now wrap text by Bunsetsu (the smallest unit of words that sounds natural) or phrases—instead of by character—for more polished and readable Japanese applications. You can take advantage of this wrapping by using android:lineBreakWordStyle=”phrase” with TextViews.

Improved Japanese text wrapping

Improved line heights for non-Latin scripts

Android 13 improves the display of non-Latin scripts (such as Tamil, Burmese, Telugu, and Tibetan) by using a line height that’s adapted for each language. The new line heights prevent clipping and improve the positioning of characters. Make sure to test your apps when using the new line spacing because the changes might affect your UI in non-Latin languages.

Android 13 improves the display of non-Latin scripts

Android 13 has some more lucrative features that can help enhance developer productivity and provide new functionalities to Android users. These include:

Predictive back gesture: In Android 13, user can use gestures to define behavior of BACK press. To predict this behavior, you need to implement ‘OnBackPressedDispatcher’ and ‘OnBackPressedCallback’ to support Back navigation. You also need to opt in to supporting the predictive back gesture. To opt in, in ‘AndroidManifest.xml’, in the ‘<application>’ tag, set the ‘android:enableOnBackInvokedCallback’ flag to true.

MIDI 2.0: Android 13 adds support for the new MIDI 2.0 standard, including the ability to connect MIDI 2.0 hardware through USB. This was introduced in late 2020 and adds bi-directional communication so MIDI 2.0 devices can exchange information on available functionality and auto configure themselves.

Bluetooth LE Audio: Low Energy (LE) Audio is the next-generation wireless audio built to replace Bluetooth classic and enable new use cases and connection topologies. It will allow users to share and broadcast their audio to friends and family, or subscribe to public broadcasts for information, entertainment, or accessibility. It’s designed to ensure that users can receive high fidelity audio and seamlessly switch between different use cases that were not possible with Bluetooth Classic without sacrificing battery life. Android 13 adds built-in support for LE Audio, so developers should get the new capabilities for free on compatible devices.

Color vector fonts: Android 13 adds rendering support for COLR version 1 (COLRv1) fonts and updates system emoji to the COLRv1 format. COLRv1 is a new and highly compact font format that renders quickly and crisply at any size. For most apps, the system handles everything and COLRv1 just works. However, if your app implements its own text rendering and uses the system’s fonts, we recommend testing emoji rendering.

Faster hyphenation: With hyphenation performance optimized by 200%, developers can enable Android 13 in ‘textview’ with almost no impact on rendering performance. New ‘fullFast’ or ‘normalFast’ frequencies in ‘setHyphenationFrequency()’ can be used to enable faster hyphenation.

Graphics and Media

Let us examine some components of Android 13 that help users work with content. Programmable shaders let users customize visual content while Anticipatory Audio routing simplifies streaming for audio content.

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.

Anticipatory Audio routing feature helps media apps for identifying route of their audio. The new ‘getAudioDevicesForAttributes()’ and ‘getDirectProfilesForAttributes()’ APIs allow you to retrieve a list of devices that may be used to play the specified audio and whether your audio stream can be played directly.

Privacy and security

While using a mobile device, users tend to share a lot of personal data that they want to remain protected which makes concerns of privacy and security worthy of attention. The latest release has brought some striking modifications to strengthen privacy and security for Android users. Major changes include:

Photo picker: Users often use photos or videos for sharing. Every time they do, they need a runtime permission to access internal/external storage, which can be tedious. With the new Android 13 photo picker, you don’t need to.

Just launch the ‘Intent(MediaStore.ACTION_PICK_IMAGES)’ and you will receive your selected media in ‘registerForActivityResult’ callback.

Here are a few more things you can do with the photo picker:

  • To pick a single image or video you can configure intent like:
                    Intent (MediaStore.ACTION_PICK_IMAGES) 
                        . apply { 
                            type = "image/*" or “video/*” 
                        } 
  • To pick multiple images or videos just add this to above shown intent
            putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, maxNumPhotosAndVideos)

Developer downgradable permission: To enhance user privacy, a newly added API can help revoke runtime permissions previously granted to the app.

For this, pass permission name into ‘revokeOwnPermissionOnKill()’ and the revocation happens asynchronously if it is safe to do so. For an example, Revocation will not happen if your app is in the foreground or if any other app is accessing your app component.

APK Signature Scheme v3.1: The APK Signature Scheme v3.0 had rotation challenges which are now resolved with the introduction of version 3.1 that provides support for original and rotated signers in single APK. Please note that v3.1 is using a new block ID that is not recognized by Android 12L or lower. Here are the highlights of signer behavior on the platform:

  • Rotated signers will be used in v3.1 in device running Android 13
  • Device running lower version that can ignore the rotate signer

Safer exporting of context-registered receivers: To make receivers safer, Android 13 allows you to enable/disable external broadcast to your app. To implement this, follow the steps below:

  • Enable the ‘DYNAMIC_RECEIVER_EXPLICIT_EXPORT_REQUIRED’ in compatible framework
  • Refer below code snippet

// This broadcast receiver should be able to receive broadcasts from other apps similar to “exported” attribute to true in your app’s manifest.

‘context.registerReceiver(sharedBroadcastReceiver, intentFilter, RECEIVER_EXPORTED)’

// For app safety reasons, this private broadcast receiver should **NOT** be able to receive broadcasts from other apps.

‘context.registerReceiver(privateBroadcastReceiver, intentFilter, RECEIVER_NOT_EXPORTED)’

Note: If you enable ‘DYNAMIC_RECEIVER_EXPLICIT_EXPORT_REQUIRED’, you must specify either ‘RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED’ for each broadcast receiver. Otherwise, the system throws SecurityException.

User Experience

To enhance user experience, Android 13 comes with clipboard improvements. In previous Android versions, users often found it confusing to understand if content was copied and if it was right. Android 13 takes care of this using clipboard preview. With ‘ClipboardManager,’ you can avoid content duplication and flag sensitive content (refer to image below).

User Experience ClipboardManager

Core Functionality

Besides the list of improvements discussed so far, Android 13 also came with OpenJDK 11 update 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.

Stay Tuned for More Android 13 News

With the changes in features and APIs discussed above, Android 13 promises an easier access to users. Now, you may be curious to understand how these changes will impact the older apps in a new mobile device. To understand this, please stay tuned for the next article, “Effects of on old app running on Android 13 device.”

Check out Apexon’s Custome application services or get in touch directly below.

Stay Updated
Please enable JavaScript in your browser to complete this form.
LinkedIn
Share
Copy link
URL has been copied successfully!