Android 12: New changes from Google I/O 2021

Milan Vadhel
Mindful Engineering
4 min readJun 2, 2021

Hello folks, as a developer or tech enthusiast we know that we have been waiting for the Google IO event for the last 2 years. Due to pandemics, they did not launch the event last year. They have brought many new things to this year’s Google IO 2021 like LaMDA (Language model for Dialogue), Safer Routing in Google Maps, Android 12 Beta version, and many more things.

Through Android 12, users will be able to connect IoT devices. Through the auto and digital car keys, users will be able to connect the car to their mobile devices.

You will be able to use Google Assistant by long-pressing the power button of your Smartphone. Big buttons will be found in the Quick Settings of Home Control and Google Wallet.

But As an Android developer, we are always looking for new changes in the new Android OS (Android 12) to make our Apps compatible across all android devices. So without wasting your time let’s check what are the new things they brought for android developers.

Google IO
Image Credit: Smartprix.com

Android 12: One of the biggest design change

Image Credit: Android Website

Android 12 represents the biggest design revamp in the history of the OS. Everything from the lock screen to the home screen and system settings has been revamped. They made Android 12 more expressive, dynamic, and personal by Unveiling Material You (New Design Language) for the next stage for Material Design.

Redesigned widgets

Image Credit: Android Website

Android 12 Redesigned and added some improvements in Widget to make them colorful, useful, and interactable by interactive controls to make the personalized experience better. Another amazing thing for developers is dynamic color APIs which adopt the system colors which create consistent looks.

Stretch overscroll

Image Credit: Android Website

The stretch overscroll effect is giving a natural experience to your app’s users while over scrolling the list type of the contents like ListView, RecyclerView, ViewPager, etc and it is enabled by default. This overscroll effect replaces the glow effect which was supported in previous versions. If you need to, you can just opt-out.

Nearby device permissions

Previously we were getting Location permission in Bluetooth type applications to scan nearby devices. But actually, there is no need for that. So to avoid that the Android 12 comes with new permission BLUETOOTH_SCAN to scan nearby devices with usesPermissionFlags=”neverForLocation” attribute.

After pairing the device, you have to use BLUETOOTH_CONNECT permission to interact with it which gives a privacy-friendly design experience.

Approximate location

Image Credit: Android Website

While we are making the location-based apps we need the ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION. But, now things are different with Android 12.

When you make an app with the support of Android 12 and you want location permission from the user and if you request only ACCESS_COARSE_LOCATION then it does not affect but if you request ACCESS_FINE_LOCATION you must also request ACCESS_COARSE_LOCATION permission which is considered as user’s privacy and gives choice to the user’s for which type of location they want to share with your apps.

If you try to request only ACCESS_FINE_LOCATION then the system simply ignores the request and throws an error message in Logcat: ACCESS_FINE_LOCATION must be requested with ACCESS_COARSE_LOCATION.

Splash Screen API

Android 12 added a new Splash Screen API which enables new app launch animation. You can add branding image, animated icon, window background, and Animation duration directly in your themes.xml file like below.

<style name="SplashTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:windowSplashScreenBackground">@color/colorDarkGreen</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_splash</item>
<item name="android:windowSplashScreenAnimationDuration">@integer/splash_delay</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:statusBarColor">@color/colorDarkGreen</item>
</style>

You can also Customize the animation for dismissing the splash screen using splashScreen.setOnExitAnimationListener{}

Notification trampoline restrictions

Whenever users launch your app by tapping on Notification we generally use service and broadcast receiver to start the activity. But now you can not call startActivity() from Service or Broadcast receiver.

To improve the performance of the app they restricted that thing. So to update your app you need to use the PendingIntent object which is associated with your activity. Which reduces latency for apps that are started from a notification.

Foreground Service Restrictions

In Android 12 the system can delay to show the foreground service notifications by 10 seconds. So it will complete its task before it will display notification. If your foreground service follows some characteristics then it will display the notification immediately as soon as it starts :

  • The service contains an action button.
  • The service has a foregroundServiceType of mediaPlayback, mediaProjection, or phoneCall.
  • The service provides use case-related work like media playback, phone calls.

You can opt-out of this behavior change by calling setShowForegroundImmediately().

I hope you got the idea of what are the new changes in the Android 12. Stay tuned for the next update.

You may read about DataBinding, Dagger2, Hilt, Coroutine.

Written by Rina Thakkar, Milan Vadhel

--

--