Exploring Android Q: Settings Panels

272 阅读2分钟
原文链接: medium.com

Exploring Android Q: Settings Panels

Go to the profile of Joe Birch
Joe BirchBlockedUnblockFollowFollowing
This article was originally posted on joebirch.co/

It’s here! We recently saw the announcement of the Android Q beta release 🎉 With this version of Android comes a collection of exciting changes which we need to get our apps ready for. In my next set of articles I’m going to be diving into each one of these so that we are fully prepared for getting our apps ready!

Note: You can find the code for this article here.

As outlined in the beta release notes for Android Q, one of the new features we are seeing introduced is what are known as Settings Panels. These allow us to launch panels which show commonly used settings within our apps — meaning that the user can toggle settings without having to switch context, let alone find the setting that it is they want to access. This new piece of functionality gives us access to three different settings panels, which all can be launched via a simple startActivity() call.

Each of these provides a way for the user to configure settings for these things. These settings panels require very little code to launch, we can do so with a single line of code:

startActivity(Intent(panel))

The panel argument that we pass in to this intent instance is a reference to a string value defined within the Panel class.

Internet Connectivity

We can launch the internet connectivity panel by passing in the ACTION_INTERNET_CONNECTIVITY value when instantiating our intent:

Settings.Panel.ACTION_INTERNET_CONNECTIVITY

As you can see in the screenshot below, this gives our user the ability to quickly:

  • Toggle airplane mode
  • Toggle Wifi connectivity
  • Change their Wifi network connection
  • Navigate to connectivity settings

Showing this panel could be handy in situations such as:

  • Prompting the user to connect to your wifi network (although, Q provides some extra functionality for this which we will cover in another post)
  • Detecting a problem with the connection, prompting the user to check their settings

Volume

Maybe your app handles some form of media playback or calls — in these cases it’s likely that you’ll be handling audio in some way. In this case, you’ll be able to make use of the volume panel by using the ACTION_VOLUME value:

Settings.Panel.ACTION_VOLUME

The volume panel shows several different volume options:

  • Media volume
  • Call volume
  • Ring volume
  • Alarm volume

Note: It currently looks like theres a bug where the text for each volume setting is being cut-off

NFC

If your application makes use of NFC technology then there is also an NFC panel that you can make use of. This can be done by using the ACTION_NFC value:

Settings.Panel.ACTION_NFC

This simply shows NFC settings to the user. For me on my device I am just seeing a switch that launches the NFC preferences screen, maybe in future this will operate different or make us of clearer copy.