Categories Content Providers

How to properly implement Android Q Settings Panel

15 Mar. 2019
2
0
7 minutes

To date, we do not know yet which dessert will be chosen by the Android team to represent Android Q version. However, we have a lot of information regarding the new features it includes. Indeed, Android opened Android Q Beta on March 13, 2019. As a result, we were able to test the new features in this latest version.

Android Q

Android Q brings a number of additional privacy and security features for users, as well as new APIs for connectivity, telephony, accessibility, and more. It also includes some enhancements for foldable devices. Android published detailed articles with regard to behaviour changes, privacy
enhancements
and new features.

For now, Android Q Beta is only available on Google Pixel devices (Pixel 3, Pixel 3 XL, Pixel 2, Pixel 2 XL, Pixel, or Pixel XL). Nevertheless, it is possible to set up an Android Emulator to run Android Q Beta. The procedure is described in Get Android Q Beta article.

Introduction

Among these new features, there are Settings Panels. It allows apps to show a subset of settings through a floating component within an app. As a result, it prevents users from needing to go into Settings to enable the required features to use an app.

For instance, suppose a user opens an application including a WebView while its device is in airplane mode. Prior to Android Q, the app could only invite the user to Open Settings to restore connectivity. This switch of context tended to degrade the User Experience. With Android Q, the app can directly display an embedded panel showing connectivity settings. Settings Panels allows users to tweak some settings without leaving the application.

Android Q – Connectivity Panel

This new feature gives developers access to three different panels :

  • Connectivity Panel: It shows settings related to internet connectivity, such as Wi-Fi, Airplane mode and Mobile Data.
  • Volume Panel: It displays volume settings for all audio streams, as well as the Do not disturb option.
  • NFC Panel: It shows settings related to near-field communication.

Video

Setup

First and foremost, you need to set up the Android Q SDK. In order to achieve this, two updates are required in Tools > SDK Manager. Android Q Preview (or higher) must be installed in SDK Platforms tab. Furthermore, Android SDK Build-Tools 28 (or higher) is also required. It can be installed in SDK Tools tab.

Afterwards, it is necessary to update the build configuration of your app as follows:

android {
    compileSdkVersion 'android-Q'

    defaultConfig {
        targetSdkVersion 'Q'
    }
    ...
}

Implementation

Displaying a Settings Panel requires very little code. All you need to do is create an Intent specifying the desired action, then start an activity with this intent.

It is important to notice that an exception will be thrown if such an intent in started on older versions.

Connectivity Panel

Connectivity Panel

The Connectivity Settings Panel allows users to configure Wi-Fi and Airplane mode. Each panel has a link See more to the Settings activity.

val connectivityPanelIntent = Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY)
startActivityForResult(connectivityPanelIntent)
Intent connectivityPanelIntent= new Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY);
startActivityForResult(connectivityPanelIntent);

Volume Panel

Volume Panel

Android Q is in Beta so there are bugs, such as this display issue. There are four sliders to control Media, Call, Ring and Alarm volumes.

val connectivityPanelIntent = Intent(Settings.Panel.ACTION_VOLUME)
startActivityForResult(connectivityPanelIntent)
Intent connectivityPanelIntent= new Intent(Settings.Panel.ACTION_VOLUME);
startActivityForResult(connectivityPanelIntent);

NFC Panel

NFC Panel

The toggle is not available because the emulator hasn’t NFC.

val connectivityPanelIntent = Intent(Settings.Panel.ACTION_NFC)
startActivityForResult(connectivityPanelIntent)
Intent connectivityPanelIntent= new Intent(Settings.Panel.ACTION_NFC);
startActivityForResult(connectivityPanelIntent);

Download

  • Kotlin
  • Java

Conclusion

Android Q Settings Panels provide a way to change commonly used settings quickly and without context change. It offers a great User Experience. This feature is a nice addition to the Android system and I’m confident that it will evolve.

Leave a Reply

Your email address will not be published. Required fields are marked *