Category Archives: Android Developers Blog

An Open Handset Alliance Project

Per-App Language Preferences – Part 2

Posted by Neelansh Sahai Android Developer Relations Engineer (on Twitter and LinkedIn)

Context

In part 1 of the Per-App Language Preferences blog, we discussed what the feature is, how developers benefit from it, how to implement the feature, and the strong business impact of catering to multilingual users. In this part of the blog, we'll discuss how various top apps migrated to the Per-App Languages Feature and how it benefited them.

Developer Success Stories

Here are some top apps that migrated to the Per-App Languages Preferences APIs. Let’s have a look at them.
LinkedIn Logo

LinkedIn is a business and employment oriented online platform that is primarily used for professional networking and career development. It bridges the gap between an employer and a job seeker, by providing both a common ground to connect. LinkedIn operates over a huge set of 875+ M registered users spread across more than 200 countries and territories.

Due to the several regions they cover, it becomes important to support multiple languages in the app. LinkedIn supports 26 Languages in their app right now, and this brings forward an opportunity to provide the users with the best experiences of latest android features. With this as the target, the LinkedIn team invested their efforts in migrating to the new Per-App Language Preferences APIs, and went ahead to provide their consumers the complete flexibility and features of Android 13. The team also quoted, “It was an easy integration with minimal code changes”.


MyJio Logo

MyJio is the-one-stop destination for recharges, managing accounts & Jio devices, UPI & payments, entertainment services with movies, music, news, games, quizzes & a lot more. With over 500 M+ total installs spread across the globe, MyJio aims to provide its users better access to a variety of utilities. Also as the user-base of MyJio is quite vast, the app supports a total of over 12+ Languages. With these many features and a wide diversity of active multilingual users, MyJio has a strong reason to localize their app using the best practices.

MyJio developers implemented the Per App Language Preferences APIs right along with the Android 13 release, allowing their users the flexibility to select a language for their app from system settings as well.

One of the major use-cases was to retain user's language preference, when users switch devices and then log in again from the same account. In this case, when the data is restored from a previous backup, the language preference is also restored along with the rest of the data, maintaining the seamless MyJio user experience across devices. This shows the API's flexibility to work well with other Android features like Backup and Restore, and helps developers give their users a better user experience.
 

Zomato Logo
With over 16.7M+ monthly transacting customers in more than 1000 cities across India, it is one of the most popular food ordering and restaurant discovery services in the region. This also means that the app is used in several languages. Zomato currently supports over 15 languages on its app.

The Zomato team wanted to make the user experience for users across geographies to be very seamless and delightful. Localizing the app based on the region and user preference was an important step in this direction. Zomato was quick to respond to the changes that were introduced in Android 13. They went ahead and migrated their language-switching logic to Per-App Language Preferences, within a week. Thereby helping their users find an easy way to use Zomato in their preferred language.

FROM  THE  DEVELOPERS :

At Zomato, providing the best customer experience possible is the core of our business and we believe localization is very critical in giving our customers a pleasant experience on the platform. Our team integrated with the new A13 Per-App Language Preferences API provided by Google to make it easy for our users to switch their preferred language on Zomato.

The ease of integrating the API helped us get it done effortlessly in less than a week’s time. Backward compatibility and stability of the API ensured that we are not compromising on the experience of our customers. With this, we hope to provide a better experience to the customer in their journey of online ordering via Zomato.


OkCredit Logo

OkCredit is a credit management app with over 50M+ downloads, having total annual transactions of around 50 Billion USD on the app. As OKCredit supports both local and large-scale businesses and also around 10+ languages in their app, it was critical for them to support the ability to seamlessly switch the app language so that more users are able to onboard on their platform.

The developers from OkCredit have always been quick to adopt changes introduced in Android. They recently adopted the Per-App Language Preferences APIs within the timeframe of a week, providing their end users a better and more seamless experience around switching their app languages at their convenience.


FROM  THE  DEVELOPERS :

The demand for using apps in vernacular language is steadily growing in India. After Google announced Per-App Language Preferences recently, it was a straightforward decision to integrate them. The implementation was straightforward, stable, and compatible with older Android versions.



Conclusion

We saw that some top apps have implemented the Per-App Language Preferences APIs in their apps and have also circulated the updates out to the users. This easy migration was possible in such a short timespan due to the low amount of effort investment and minimal code changes required. Lastly, here are some resources that can help you understand the feature better.

  1. Per-App Language Preferences
  2. Sample App ( Compose )
  3. Sample App ( Views )
  4. Per-app language preferences (YouTube Video)

Compose for Wear OS 1.1 is now stable: check out new features!

Posted by Kseniia Shumelchyk, Android Developer Relations Engineer

Today we’re releasing version 1.1 of Compose for Wear OS, our modern declarative UI toolkit to help developers build beautiful, responsive apps for Wear OS.

Since the first stable release earlier this year, we have seen many developers taking advantage of the powerful tools and intuitive APIs to make building their app simpler and more efficient. Todoist and Outdooractive are some of the developers that rebuilt their Wear apps with Compose and accelerated the delivery of a new, functional user experience.

Todoist increased its growth rate by 50% since rebuilding their app for Wear 3 and Outdooractive reduced development time by 30% and saw a significant boost in developer productivity and better design/developer collaboration:

“Compose makes the UI code more intuitive to write and read, allowing us to prototype faster in the design phase and also collaborate better on the code. What would have taken us days now takes us hours.”

The Compose for Wear OS 1.1 release contains new features and brings improvements to existing components, focusing on UX and accessibility. We’ve already updated our samples, codelab, and Horologist libraries to work with Compose for Wear OS 1.1.


New features and APIs

The Compose for Wear OS 1.1 release includes the following new functionality (baseline profiles already added for new components):

Outlined style for Chips and Buttons

To give you additional ability to customize the user interface, we added outlined styles for Chips and Buttons. New OutlinedChip and OutlinedButton composables provide a transparent component with a thin border that can be used for medium-emphasis actions. Also available for compact versions: OutlinedCompactChip and OutlinedCompactButton.
Demonstration of OutlinedChip and OutlinedButton composables on a round watch face
OutlinedChip and OutlinedButton composables

Modifying Chip and Button shapes

Starting from version 1.1, you can also modify shapes for Chip/ToggleChip and Button/ToggleButton components using new functions overloads.
Demonstration of Different Chip and Button shapes on a round watch face
Different Chip and Button shapes

Placeholder API

A new experimental API has been added to implement placeholder support. This can be used to achieve three distinct visual effects separately or all together:

  • A placeholder background brush effect used in containers such as Chip and Cards to draw over the normal background when waiting for content to load.
  • A Modifier.placeholder() to draw a stadium shaped placeholder widget over the top of content that is being loaded.
  • A Modifier.placeholderShimmer() for gradient/shimmer effect that is drawn over the top of the other effects to indicate to users that the current state is waiting for data to load.
These effects are designed to be coordinated and shimmer and wipe-off in an orchestrated fashion.
Moving demonstration of Placeholder API usage examples on a round watch face
Placeholder API usage examples

Check out the reference docs and sample in Horologist to see how to apply the placeholder to common use cases, such as a Chip with icon and a label that puts placeholder over individual content slots and draws a placeholder shimmer on top while waiting for data to load.

Modifier.scrollAway

Horologist’s fadeAway modifier has been graduated to scrollAway modifier in version 1.1. Modifier.scrollAway scrolls an item vertically in and out of view, based on the scroll state, and already has overloads to work with Column, LazyColumn and ScalingLazyColumn.

Use this modifier to make TimeText fade out of the view as the user starts to scroll a list of items upwards.
Moving demonstration of ScrollAway modifier usage with TimeText on a round watch face
ScrollAway modifier usage with TimeText

Additional parameters in CurvedTextStyle

CurvedTextStyle now supports additional parameters (fontFamily, fontWeight, fontStyle, fontSynthesis) to specify font details when creating a curved text style. Extended curved text style can be used on both curvedText and basicCurvedText.

Demonstration of applying different font to curved text on a round watch face
Applying different font to curved text

UX and accessibility improvements

The 1.1 release also focuses on bringing a refined user experience, improvements for TalkBack support and overall better accessibility:

  • ToggleChip and SplitToggleChip support usage of animated toggle controls (Checkbox, Switch and RadioButton) that can be used instead of the static icons provided by ToggleChipDefaults.
  • Default gradient colors for Chip/ToggleChip and Cards were adjusted to match the latest UX specification.
  • Updated a number of the default colors in the MaterialTheme to improve accessibility as the original colors did not have sufficient contrast.
  • Accessibility improvements to Picker so that multi-picker screens are navigable with screen readers and the content description is accessible.
  • InlineSlider and Stepper now have button roles, so that TalkBack can recognize them as buttons.
  • The PositionIndicator in Scaffold is now positioned and sized so that it only takes the space needed. This is useful when semantic information is added to it, so TalkBack gets the correct bounds of the PositionIndicator on screen.

It’s time ⌚ to bring your app to the wrist!

Get started

To begin developing with Compose for Wear OS, get started with hands-on experience trying our codelab, and make sure to check out the documentation and samples. Visit Compose for Wear OS release notes for full list of changes available in version 1.1.

Note that using version 1.1 of Compose for Wear OS requires using the version 1.3 of androidx.compose libraries and therefore Kotlin 1.7.10. Check out the Compose to Kotlin Compatibility Map for more information.

Provide feedback

Compose for Wear OS continues to evolve with the features you’ve been asking for. Please do continue providing us feedback on the issue tracker and join Kotlin Slack #compose-wear channel to connect with the Google team and dev community.

We’re excited to see a growing number of apps using Compose for Wear OS in production, and we’re grateful for all issues and requests that help us to make the toolkit better!

Start building for Wear OS now

Discover even more with technical sessions from the Android Dev Summit providing guidance on app architecture, testing, handling rotary input, and verticalized sessions for media and fitness.

Android 13 for TV is now available

Posted by Wolfram Klein, Product Manager, Android TV OSToday we’re releasing the newest version of Android TV OS, Android 13 for TV! This latest release brings further improvements in performance and accessibility to help our developers build engaging apps for the next generation of TVs.

Here’s a look at some of what’s new in Android 13 for TV.

Performance and Quality

Android 13 brings new APIs to the big screen that help developers deliver high quality experiences to users across different device types.

  • Improvements to the AudioManager API allow developers to anticipate audio attribute support for the active audio device and select the optimal format without starting playback.
  • Users can now change the default resolution and refresh rate on supported HDMI source devices for a more reliable playback experience.
  • HDMI state changes are now surfaced to the MediaSession lifecycle, allowing TV dongles and other HDMI source devices to save power and pause content in reaction to HDMI state changes.

Accessibility and Input Controls

Android 13 brings new features to make interacting with TV more adaptable.

  • The InputDevice API now supports different keyboard layouts. Game developers can also reference keys by their physical location to support different layouts of physical keyboards.
  • A newly created audio descriptions API in AccessibilityManager allows your app to query the new system-wide audio description preference setting, helping developers provide audio descriptions in line with a user’s preference automatically.

Check out the Android TV OS developer site for details on even more features that come with Android 13 on TVs. The new release is now available for both ADT-3 and the Android TV emulator, and developers can choose to test on either the Google TV interface or the standard Android TV interface. As always, we are thankful to our developers for the continued support of Android TV OS. We can’t wait to see what amazing and innovative experiences you’ll continue to build for the big screen.

Google Play Coffee break with Creatrip | Setting up your business for global reach

Posted by Aditya Swamy, Director, Google Play PartnershipsI sat down for a “virtual coffee” with Haemin Yim, founder and CEO of Creatrip, from Korea to discuss starting on the web, setting up the company for global reach, and tips for startups looking to grow.

In Haemin’s words “Creatrip is an app that provides a gateway to authentic Korean trends and cultures.” Last year, they took part in the ChangGoo program, an initiative that supports Korean app startups in partnership with the South Korean government. The Creatrip team applied the learnings of the program to continue to grow and now have users from over 100 countries.Here are my key takeaways from our conversation:
illustration of three people in a rowboat at sea during a storm. The person at the helm is looking at weather related data

Expanding the app's value proposition to address challenges

Despite having a great idea for an app, Haemin shared with me that it hasn’t always been smooth sailing. After gaining significant brand awareness and with increasing travel bookings across the app, the pandemic sent the travel industry into disarray. As with many businesses, this had significant implications for Creatrip. However, Haemin and the team used their strong understanding of the people using their app to quickly expand their offering.

With the knowledge that people often wanted to visit South Korea because of their interest in K-trends and culture; Haemin adapted the business to provide K-products to those who were unfortunately unable to travel during that period. This led Haemin to grow the business beyond just a travel app and into a global e-commerce platform.

Creating new content to fuel app growth

Creatrip started as an app that provided travel content. It quickly expanded to provide people with in-app booking features, local currency exchange rates that weren’t previously digitized, and even a global e-commerce platform providing access to popular ‘K-items’. However, content is the key element that draws users into the app.

My top advice for businesses looking to continue to evolve their content is to expand their content creator pipeline. For example, by encouraging South Korean locals to contribute, Creatrip could gain a richer and more diverse range of content, showcasing Korea through the eyes of many different people. Haemin and the team are already in the process of building a new feature that allows people to create their own content on the app.

Think about short form video apps. By allowing people to become their own content creators, it enables them to have a much wider repository of content and encourages users to spend more time on the app. Now more people want to be creators and make their own content as seen on YouTube. This is fueling growth in watchtime, and adding more users.

illustration of two people receiving global information on shopping, popular items, trends, data, and people via their laptop and phone screen

Going global from the start

Something I found particularly interesting from my chat with Haemin, was how she prepared the business for global reach from the start. Haemin believes that despite requiring a bit more time and effort, preparing for global reach from the beginning can actually allow for exponential growth, as you start to target the right markets and reach a global fan base. It is wonderful to see how Haemin brings her passion for all things Korean, to people all around the world. The team’s first step towards going global was by listening to and understanding the needs of the people already using Creatrip.

The team at Creatrip have definitely brought a lot of unique ideas to the app. With 90% of their users having started on the website, the team had an ingenious idea to bring people over to mobile. They listened to their global users and saw that people were keen to find out the currency exchange rates being provided at local stores in Seoul. They created a mobile-only feature that shows local currency rates from local stores. This required the team to actually go to the stores twice a day, however it led to a large increase in people using the mobile app - all by providing information that was previously unavailable to people from outside of Seoul.

Planning for the future

It’s amazing to see how much Creatrip is flourishing; the app has grown from 100k monthly users up to 1.5 million. There are many factors that helped Creatrip grow over the past few years, but some notable takeaways from my chat with Haemin include:

  1. Taking the time to understand the people using their apps and their needs
  2. Launching app only features to drive people from web to the app
  3. Using content as a means to get new users and increase engagement
For Haemin, there are still a lot of opportunities ahead. She believes that the ‘K-phenomenon’ will keep growing for the foreseeable future and this will aid more travel across South Korea. The team at Creatrip is focused on continuing to expand the cross-border shopping experience so people can buy South Korean trending products, no matter what country they live in. I can’t wait to see how Creatrip continues to bring the magic of Korea to the world.

As a final thought I couldn't let Haemin go without asking her favorite K trends. She mentioned that fusion fine dining was a top trend in Korea, NewJeans were a trending K-pop band, and South Korean blankets were a top K-product.

Do you have any questions for Creatrip? What are your own tips for other app or game businesses? Let us know on Twitter.


Google Play logo

Google Play Coffee break with Creatrip | Setting up your business for global reach

Posted by Aditya Swamy, Director, Google Play PartnershipsI sat down for a “virtual coffee” with Haemin Yim, founder and CEO of Creatrip, from Korea to discuss starting on the web, setting up the company for global reach, and tips for startups looking to grow.

In Haemin’s words “Creatrip is an app that provides a gateway to authentic Korean trends and cultures.” Last year, they took part in the ChangGoo program, an initiative that supports Korean app startups in partnership with the South Korean government. The Creatrip team applied the learnings of the program to continue to grow and now have users from over 100 countries.Here are my key takeaways from our conversation:
illustration of three people in a rowboat at sea during a storm. The person at the helm is looking at weather related data

Expanding the app's value proposition to address challenges

Despite having a great idea for an app, Haemin shared with me that it hasn’t always been smooth sailing. After gaining significant brand awareness and with increasing travel bookings across the app, the pandemic sent the travel industry into disarray. As with many businesses, this had significant implications for Creatrip. However, Haemin and the team used their strong understanding of the people using their app to quickly expand their offering.

With the knowledge that people often wanted to visit South Korea because of their interest in K-trends and culture; Haemin adapted the business to provide K-products to those who were unfortunately unable to travel during that period. This led Haemin to grow the business beyond just a travel app and into a global e-commerce platform.

Creating new content to fuel app growth

Creatrip started as an app that provided travel content. It quickly expanded to provide people with in-app booking features, local currency exchange rates that weren’t previously digitized, and even a global e-commerce platform providing access to popular ‘K-items’. However, content is the key element that draws users into the app.

My top advice for businesses looking to continue to evolve their content is to expand their content creator pipeline. For example, by encouraging South Korean locals to contribute, Creatrip could gain a richer and more diverse range of content, showcasing Korea through the eyes of many different people. Haemin and the team are already in the process of building a new feature that allows people to create their own content on the app.

Think about short form video apps. By allowing people to become their own content creators, it enables them to have a much wider repository of content and encourages users to spend more time on the app. Now more people want to be creators and make their own content as seen on YouTube. This is fueling growth in watchtime, and adding more users.

illustration of two people receiving global information on shopping, popular items, trends, data, and people via their laptop and phone screen

Going global from the start

Something I found particularly interesting from my chat with Haemin, was how she prepared the business for global reach from the start. Haemin believes that despite requiring a bit more time and effort, preparing for global reach from the beginning can actually allow for exponential growth, as you start to target the right markets and reach a global fan base. It is wonderful to see how Haemin brings her passion for all things Korean, to people all around the world. The team’s first step towards going global was by listening to and understanding the needs of the people already using Creatrip.

The team at Creatrip have definitely brought a lot of unique ideas to the app. With 90% of their users having started on the website, the team had an ingenious idea to bring people over to mobile. They listened to their global users and saw that people were keen to find out the currency exchange rates being provided at local stores in Seoul. They created a mobile-only feature that shows local currency rates from local stores. This required the team to actually go to the stores twice a day, however it led to a large increase in people using the mobile app - all by providing information that was previously unavailable to people from outside of Seoul.

Planning for the future

It’s amazing to see how much Creatrip is flourishing; the app has grown from 100k monthly users up to 1.5 million. There are many factors that helped Creatrip grow over the past few years, but some notable takeaways from my chat with Haemin include:

  1. Taking the time to understand the people using their apps and their needs
  2. Launching app only features to drive people from web to the app
  3. Using content as a means to get new users and increase engagement
For Haemin, there are still a lot of opportunities ahead. She believes that the ‘K-phenomenon’ will keep growing for the foreseeable future and this will aid more travel across South Korea. The team at Creatrip is focused on continuing to expand the cross-border shopping experience so people can buy South Korean trending products, no matter what country they live in. I can’t wait to see how Creatrip continues to bring the magic of Korea to the world.

As a final thought I couldn't let Haemin go without asking her favorite K trends. She mentioned that fusion fine dining was a top trend in Korea, NewJeans were a trending K-pop band, and South Korean blankets were a top K-product.

Do you have any questions for Creatrip? What are your own tips for other app or game businesses? Let us know on Twitter.


Google Play logo

Per-App Language Preferences – Part 1

Posted by Neelansh Sahai Android Developer Relations Engineer (on Twitter and LinkedIn)What if you have a set of users who are quite fluent in English, Hindi, and Spanish, and they have a news app on their phones and prefer to read the news in Hindi? For their texting app, they prefer Spanish as they have some friends and family who they text with in Spanish. But for ease of access, they still prefer their device to be in English. Now there are many such use-cases where the users might want their app languages to be different from their system language. Interesting!

Starting with Android 13, we have included one of the most-requested features from users, Per-App Language Preferences. It lets users switch app languages from System settings, providing users with better control over their language choices for different apps, irrespective of the system language.
A cellphone screen displaying App language preferences in system settings for the YouTube app

Build for your multilingual users

This blog focuses on how to integrate the Per-App Language Preferences API in your app to provide your users the flexibility to choose different languages for different apps.

1.    Users can change the language settings from system settings by selecting: 

Settings → System → Languages & Input → App Languages → [Select the desired App] → [Select the desired Language]

NOTE: Only those apps that have opted in for the feature by specifying the locale_config.xml file (more on this below), will appear in system settings.

A cellphone screen demonstrating finding the language settings from system settings by selecting Settings → System → Languages & Input → App Languages → [Select the desired App] → [Select the desired Language]
2.    If your app already has an in-app language picker, you can integrate the Per-App Language Preferences API to leverage the full platform support. For pre-Android 13 users, the system settings won’t be visible, but developers can still provide an in-app language picker.

A cellphone screen demonstrating integrating the Per-App Language prefences API for an app which already has an in-app language picker

How to integrate this feature in your app?

There are 5 steps that need to be followed while working on the Per-App Language Preferences feature, listed here →

 


1.    Create locale_config.xml file


Create a new file in values/xml/ directory and name it as locale_config.xml. This file should contain a list of all the locales that are supported by the app. The list element should be a string containing a locale tag.

NOTE: The locale tags must follow the BCP47 syntax, which is usually {language subtag}–{script subtag}–{country subtag}. Anything other than that will be filtered out by the system and won't be visible in the system settings.


locale_config.xml

<?xml version="1.0" encoding="utf-8"?>
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
    ...

    <!-- English -->
    <locale android:name="en"/>



    <!-- Japanese (Japan) -->          
    <locale android:name="ja-JP"/>



    <!-- Chinese (Macao) in Simplified Script -->
    <locale android:name="zh-Hans-MO"/>



    <!-- Chinese (Taiwan) in Traditional Script -->
    <locale android:name="zh-Hant-TW"/>  
    ...
</locale-config>





2.    Add the locale_config in the AndroidManifest.xml

Specify this locale_config.xml file in the app’s AndroidManifest.xml

AndroidManifest.xml

<manifest>
    ...
    <application
        ...
        android:localeConfig="@xml/locale_config">
    </application>
</manifest>


After steps 1 & 2, your users will be able to discover and set their language preference for your app from system settings on devices running Android 13 or higher. In case your users are on devices running on versions lower than Android 13, you can provide an in-app language picker. Optionally, you can also include the same language picker in your app for devices running Android 13 or higher. When your app includes an in-app language picker, it's important for the user's preferences to be in sync between the system and the app. This is where the AndroidX APIs come into the picture. Read on to learn how to create an in-app language picker.




3. Add the libraries

Use the latest version of AppCompat Library

build.gradle (app)

def latestAppCompatVersion =  “1.6.0-rc01”

dependencies {
    ...
    implementation "androidx.appcompat:appcompat:$latestAppCompatVersion"
    implementation "androidx.appcompat:appcompat-resources:$latestAppCompatVersion"
    ...
}




4. Use AndroidX APIs

Use the APIs in your code to set and get the app locales.

MainActivity.kt

val appLocale: LocaleListCompat = LocaleListCompat.forLanguageTags("xx-YY")

// Call this on the main thread as it may require Activity.restart()
AppCompatDelegate.setApplicationLocales(appLocale)


// Call this to get the selected locale and display it in your App
val selectedLocale = AppCompatDelegate.getApplicationLocales()[0]

NOTE: These APIs are also backward compatible, so even if the app is being used on Android 12 or lower, the APIs would still behave the same, and no additional checks for OS versions are required in your code.


 
5. Delegate storage to AndroidX

Let AndroidX handle the locale storage so that the user's preference persists.

AndroidManifest.xml

<application
    ...
    <service
        android:name="androidx.appcompat.app.AppLocalesMetadataHolderService"
        android:enabled="false"
        android:exported="false">
        <meta-data
            android:name="autoStoreLocales"
            android:value="true" />
    </service>
    ...
</application>


Steps 3, 4, & 5 above demonstrate the minimum components needed to create an in-app language picker.

And with this, your app can now support locale switching.


Additional things to take care of while migrating to the API

Earlier, developers had to handle the user's preferences on their own, either by using SharedPreferences, storing the data on a server, or other app logic. With the new APIs, there is no need to handle this separately. So when you are using these APIs, AndroidX is already taking care of the storage part, but what happens when the app is opened for the first time after a user updates their device to Android 13 or higher?

In this case, the system won’t be aware of the user’s preferences for the app language and thus it will map the app to the default system language. To avoid this, developers need to add some one-time migration logic so that their users don’t have to set the language again when they update the app.

// Specify the constants to be used in the below code snippets

companion object {

    // Constants for SharedPreference File
    const val PREFERENCE_NAME = "shared_preference"
    const val PREFERENCE_MODE = Context.MODE_PRIVATE

    // Constants for SharedPreference Keys
    const val FIRST_TIME_MIGRATION = "first_time_migration"
    const val SELECTED_LANGUAGE = "selected_language"

    // Constants for SharedPreference Values
    const val STATUS_DONE = "status_done"
}




// Utility method to put a string in a SharedPreference
private fun putString(key: String, value: String) {
    val editor = getSharedPreferences(PREFERENCE_NAME, PREFERENCE_MODE).edit()
    editor.putString(key, value)
    editor.apply()
}

// Utility method to get a string from a SharedPreference
private fun getString(key: String): String? {
    val preference = getSharedPreferences(PREFERENCE_NAME, PREFERENCE_MODE)
    return preference.getString(key, null)
}


// Check if the migration has already been done or not
if (getString(FIRST_TIME_MIGRATION) != STATUS_DONE) {

   // Fetch the selected language from wherever it was stored. In this case it’s SharedPref

   // In this case let’s assume that it was stored in a key named SELECTED_LANGUAGE
  getString(SELECTED_LANGUAGE)?.let { it

      // Set this locale using the AndroidX library that will handle the storage itself
      val localeList = LocaleListCompat.forLanguageTags(it)
      AppCompatDelegate.setApplicationLocales(localeList)

      // Set the migration flag to ensure that this is executed only once
      putString(FIRST_TIME_MIGRATION, STATUS_DONE)
  }
}

 

What flexibility does the feature provide to the users and developers?

Here are a few things that might prove to be beneficial for you users.

  1. All devices running Android 13 or higher will have a common place for users to discover and change the language of their apps.
  2. Although the system settings are limited to the devices running Android 13 or higher, the AndroidX APIs are backwards compatible. Thus, there is no requirement to add OS Version checks in your code while building for your multilingual users.
  3. Developers do not need to handle configuration changes separately or worry about storing the user's selected language every time. The API handles configuration changes and stores the language preferences for you.
  4. Works with other Android features like Backup and restore. If a user switches to a new device and restores the previously backed up data, your app will retain the user’s last preferred language, thus providing your users with a better and more seamless experience.

Recap

With that, most parts of the feature are covered. So let’s have a quick recap on what we discussed in today’s read.

  1. A quick read on what Per-App Language Preferences offer to multilingual users and app developers.
  2. What end users will see on their devices.
  3. How to migrate your app to the Per-App Language Preferences APIs.
  4. A few things that need to be taken care of while migrating to the APIs to ensure a better user experience.
  5. Lastly, the benefits that end users and developers can leverage from this feature.

References

  1. Per-App Language Preferences
  2. Sample App ( Compose )
  3. Sample App ( Views )
  4. Per-App Language Preferences (YouTube Video)

App Bundles for Google TV and Android TV

Posted by Josh Wentz, Product Management, Google TV

TLDR: Google TV and Android TV will be requiring Android App Bundles that are archivable starting in May 2023 to save storage for users.

Over the past few decades, TV has transformed from linear channel surfing to on-demand content with multi-app experiences. Today, over 10,000 apps are available on Android TV OS. While software has grown exponentially, TV hardware has remained limited in capacity compared to its phone counterparts. In 2022, smartphones often have a minimum storage size of 64GB, but smart TVs have an average of just 8GB. Less storage results in users having to uninstall apps, hindering their overall TV experience. To help with this problem and others, Android introduced App Bundles in Nov 2020.


What are Android App Bundles?

Android App Bundles” (AABs) are the standard publishing format on Google Play (phones, tablets, TVs, etc) that have replaced “Android Package Kits” (APKs). App Bundles are smaller, faster, fresher, and better than its precursor. Key benefits include:

  1. Smaller Download/Storage Size - App Bundles create an average of 20% total size savings compared to its equivalent APK counterpart by optimizing for each device.
  2. Less Likely to Uninstall - Since App Bundles enables users with the option to archive (which reclaims ~60% of app storage), users can keep these and more apps on their TV despite limited storage. A quick archive/unarchive user interface is built-in to the TV. Developers can also maintain state for a frictionless later return.
  3. Applicable to All Android Surfaces - App Bundles are helpful for all Android surfaces using the Google Play store including TV, phone, tablet, watch, auto, & more.
  4. Streamlined Delivery & Security - For easier delivery, a single artifact with all of your app's code & resources allows Play store to dynamically serve an optimized app for each device configuration. For greater security, developers can also reset the upload key if it’s lost or compromised.

What is new for TV?

With TV storage confined and users having an increasing appetite for more apps, Google TV and Android TV will be requiring App Bundles starting in May 2023. While this provides about 6-months to transition, we estimate that in most cases it will take one engineer about 3-days to migrate an existing TV app from Android Package Kit (APK) to Android App Bundle (AAB). While developers can configure archiving for their mobile apps, TV apps are required to be archivable so that all users and developers can benefit on storage-constrained TVs.

For TV apps not transitioned in time, Google may hide such apps from the TV surface. If you’re working on a brand new TV app, be sure to use Android App Bundles from the start!


How can TV apps transition?

Visit our Developer Guide to learn more about how to migrate to an Android App Bundle (AAB).

All told, App Bundles bring a delightful experience to both you as developers and your users, especially in the living room. Thank you for your partnership in creating immersive content and entertainment experiences for the future of TV.

Introducing Camera Viewfinder

Posted by Francesco Romano, Developer Relations Engineer, Androidhand holding a phoneOver the years, Android devices have evolved to include a variety of sizes, shapes, and displays, among other features. Since the beginning, however, taking pictures with your phone has been one of the most important use cases. Today, camera capabilities are still one of the top reasons consumers purchase a phone.

As a developer, you want to leverage camera capabilities in your app, so you decide to adopt the Android Camera Framework. The first use case you want to implement is the Preview use case, which shows the output of the camera sensor on the screen.

So you go ahead and create a CaptureSession using a surface as big as the screen size. As long as the screen has the same aspect ratio as the camera sensor output and the device stays in its natural portrait orientation, everything should be fine.

But what happens when you resize the window, unfold your device, or change the display or orientation? Well, in most cases, the preview may appear stretched, upside down, or incorrectly rotated. And if you are in a multi-window environment, your app may even crash.

Why does this happen? Because of the implicit assumptions you made while creating the CaptureSession.

Historically, your app could live in the same window for its whole life cycle, but with the availability of new form factors such as foldable devices, and new display modes such as multi-window and multi-display, you can't assume this will be true anymore.

In particular, let's see some of the most important considerations when developing an app targeting various form factors:

Let's examine some common pitfalls to avoid when developing an app targeting various form factors:

  • Don't assume your app will live in a portrait-shaped window. Requesting a fixed orientation is still supported in Android 13, but now device manufacturers may have the option of overriding an app request for a preferred orientation.
  • Don't assume any fixed dimension or aspect ratio for your app. Even if you set resizableActivity = "false", your app could still be used in multi-window mode on large screens (>=600dp).
  • Don't assume a fixed relationship between the orientation of the screen and the camera. The Android Compatibility Definition Document specifies that a camera image sensor "MUST be oriented so that the long dimension of the camera aligns with the screen's long dimension." Starting with API level 32, camera clients that query the orientation on foldable devices can receive a value that dynamically changes depending on the device/fold state.
  • Don't assume the size of the inset can't change. The new taskbar is reported to applications as an inset, and when used with gesture navigation, the taskbar can be hidden and shown dynamically.
  • Don't assume your app has exclusive access to the camera. While your app is in a multi-window state, other apps can obtain access to shared resources like camera and microphone.

While CameraX already handles most of the cases above, implementing a preview that works in different scenarios with Camera2 APIs can be complex, as we describe in the Support resizable surfaces in your camera app Codelab.

Wouldn’t it be great to have a simple component that takes care of those details and lets you focus on your specific app logic?

Say no more…

Introducing CameraViewfinder

CameraViewfinder is a new artifact from the Jetpack library that allows you to quickly implement camera previews with minimal effort. It internally uses either a TextureView or SurfaceView to display the camera feed, and applies the required transformations on them to correctly display the viewfinder. This involves correcting their aspect ratio, scale, and rotation. It is fully compatible with your existing Camera2 codebase and continuously tested on several devices.

Let’s see how to use it.

First, add the dependency in your app-level build.gradle file:

implementation "androidx.camera:camera-viewfinder:1.3.0-alpha01"

Sync your project. Now you should be able to directly use the CameraViewfinder as any other View. For example, you can add it to your layout file:

<androidx.camera.viewfinder.CameraViewfinder
  android:id="@+id/view_finder"
  app:scaleType="fitCenter"
  app:implementationMode="performance"
  android:layout_width="match_parent"
  android:layout_height="match_parent"/>

As you can see, CameraViewfinder has the same controls available on PreviewView, so you can choose different Implementation modes and scaling types.

Now that the component is part of the layout, you can still create a CameraCaptureSession, but instead of providing a TextureView or SurfaceView as target surfaces, use the result of requestSurfaceAsync().

fun startCamera(){
    val previewResolution = Size(width, height)
    val viewfinderSurfaceRequest =
ViewfinderSurfaceRequest(previewResolution, characteristics)
    val surfaceListenableFuture =
        cameraViewfinder.requestSurfaceAsync(viewfinderSurfaceRequest)

    Futures.addCallback(surfaceListenableFuture, object : FutureCallback<Surface> {
        override fun onSuccess(surface: Surface) {
            //create a CaptureSession using this surface as usual
        }
        override fun onFailure(t: Throwable) { /* something went wrong */}
    }, ContextCompat.getMainExecutor(context))
}


Bonus: optimized layouts for foldable devices

CameraViewFinder is ready-to-use across resizable surfaces, configuration changes, rotations, and multi-window modes, and it has been tested on many foldable devices.

But if you want to implement optimized layouts for foldable and dual screen devices, you can combine CameraViewFinder with the Jetpack WindowManager library to provide unique experiences for your users.

For example, you can choose to avoid showing full screen preview if there is a hinge in the middle of the screen, or if the device is in “book” or “tabletop” mode. In those scenarios, you can have the viewfinder in one portion of the screen and the controls on the other side, or you can use part of the screen to show the last pictures taken. Imagination is the limit!

The sample app is already optimized for foldable devices and you can find the code to handle posture changes here. Have a look!

#WeArePlay | Discover what inspired 4 game creators around the world

Posted by Leticia Lago, Developer Marketing

From exploring the great outdoors to getting your first computer - a seemingly random moment in your life might one day be the very thing which inspires you to go out there and follow your dreams. That’s what happened to four game studio founders featured in our latest release of #WeArePlay stories. Find out what inspired them to create games which are entertaining millions around the globe.
Born and raised in Salvador, Brazil, Filipe was so inspired by the city’s cultural heritage that he studied History before becoming a teacher. One day, he realised games could be a powerful medium to share Brazilian history and culture with the world. So he founded Aoca Game Lab, and their first title, ÁRIDA: Backland’s Awakening, is a survival game based in the historic town of Canudos. Aoca Game Lab took part in the Indie Games Accelerator and have also been selected to receive the Indie Games Fund. With the help from these Google Play programs, they will take the game and studio to the next level.
#WeArePlay Marko Peaskel Nis, Serbia
Next, Marko from Serbia. As a chemistry student, he was never really interested in tech - then he received his first computer and everything changed. He quit his degree to focus on his new passion and now owns his successful studio Peaksel with over 480 million downloads. One of their most popular titles is 100 Doors Games: School Escape, with over 100 levels to challenge the minds of even the most experienced players.
#WeArePlay Liene Roadgames Riga Latvia
And now onto Liene from Latvia. She often braves the big outdoors and discovers what nature has to offer - so much so that she organizes team-building, orienteering based games for the team at work. Seeing their joy as they explore the world around them inspired her to create Roadgames. It guides players through adventurous scavenger hunts, discovering new terrain.
#WeArePlay Xin Savy Soda Melbourne, Australia
And lastly, Xin from Australia. After years working in corporate tech, he gave it all up to pursue his dream of making mobile games inspired by the 90’s video games he played as a child. Now he owns his studio, Pixel Starships, and despite all his success with millions of downloads, his five-year-old child gives him plenty of feedback.

Check out all the stories now at g.co/play/weareplay and stay tuned for even more coming soon.


How useful did you find this blog post?

#WeArePlay Xin Savy Soda Melbourne, Australia Google Play g.co/play/weareplay

Helping Families Find High-Quality Apps for Kids

Posted by Mindy Brooks, General Manager, Kids and FamilyApps play an increasingly important role in all of our lives and we’re proud that Google Play helps families find educational and delightful experiences for kids. Of course, this wouldn’t be possible without the continued ingenuity and commitment of our developer partners. From kid-friendly entertainment apps to educational games, you’ve helped make our platform a fantastic destination for high-quality content for families. Today, we’re sharing a few updates on how we’re building on this work to create a safe and positive experience on Play.

Expanding Play’s Teacher Approved Program

In 2020, we introduced the Teacher Approved program to highlight high-quality apps that are reviewed and rated by teachers and child development specialists. Through this program, all apps in the Play Store’s Kids tab are Teacher Approved, and families can now more easily discover quality apps and games.

As part of our continued investments in Teacher Approved, we’re excited to expand the program so that all apps that meet Play’s Families Policy will be eligible to be reviewed and shown on the Kids tab. We’re also streamlining the process for developers. Moving forward, the requirements for the Designed for Families program, which previously were a separate prerequisite from Teacher Approved eligibility, will be merged into the broader Families Policy. By combining our requirements into one policy and expanding eligibility for the Teacher Approved program, we look forward to providing families with even more Teacher Approved apps and to help you, our developer partners, reach more users.

If you’re new to the Teacher Approved program, you might wonder what we’re looking for. Beyond strict privacy and security requirements, great content for kids can take many forms, whether that’s sparking curiosity, helping kids learn, or just plain fun. Our team of teachers and experts across the world review and rate apps on factors like age-appropriateness, quality of experience, enrichment, and delight. For added transparency, we include information in the app listing about why the app was rated highly to help parents determine if the app is right for their child. Please visit Google Play Academy for more information about how to design high-quality apps for kids.

Building on our Ads Policies to Protect Children

When you're creating a great app experience for kids and families, it’s also important that any ads served to children are appropriate and compliant with our Families Policy. This includes using Families Self-Certified Ads SDKs to serve ads to children. We recently made changes to the Families Self-Certified Ads SDK Program to help better protect users and make life easier for Families developers. SDKs that participate in the program are now required to identify which versions of their SDKs are appropriate for use in Families apps and you can view the list of self-certified versions in our Help Center.

Next year, all Families developers will be required to use only those versions of a Families Self-Certified Ads SDK that the SDK has identified as appropriate for use in Families apps. We encourage you to begin preparing now before the policy takes full effect.


Building Transparency with New Data Safety Section Options

In the coming weeks, all apps which include children in their target audience will be able to showcase their compliance with Play’s Families Policy requirements with a special badge on the Data safety section. This is another great way that you can better help families find apps that meet their needs, while supporting Play’s commitment to provide users more transparency and control over their data. To display the badge, please visit the "Security practices" section of your Data safety form.

Screenshot of a cellphone screen showing the Data Safety form in Google Play with the 'Security practices'section highlighted

As always, we’re grateful for your partnership in helping to make Play a fantastic platform for delightful, high-quality content for kids and families. For more developer resources: