Open In App

Quick Settings Tile API in Android 13

Last Updated : 28 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Users can easily modify settings or perform short actions without leaving an app’s context by using Quick Settings in the notification shade. We’re making it simpler for users to find and add their own tiles to Quick Settings for apps that offer them. Your app may now ask the user to directly add your unique tile to the collection of Quick Settings tiles by using a new tile placement API. Instead of having to navigate to Quick Settings, a new system dialogue enables users to install the tile in a single step without leaving their program. 

The user will be prompted to choose if they wish to add the displayed TileService to their current tiles after calling this. The system may cease handling requests for a specific ComponentName after a certain number of requests, and the user may reject the request. A tile that can be added to Quick Settings is provided by a TileService to the user. Without leaving the context of their current app, the user can change settings and perform rapid actions in the Quick Settings area. The lifespan of a TileService differs from that of several other services in that it can occasionally be unbound. Any of the following service lifecycle events may independently occur in a different binding or creation.

You can use this in conjunction with the newly released clipboard preview API to create even better experiences, both of them are debuting together in the latest Android’s serve, and are a treat to the user’s app. They truly change how convenient it gets to use your device once enabled in your app. There is a better confirmation of content getting copied in this newer taste of Android. This is what the new confirmation accomplishes:

  • Gives a sneak peek at the duplicated text.
  • Confirms that the content was copied successfully.

Using both these two APIs together will yield new experiences for the users and usher in more growth. We recommend giving a visible pop-up in-app widget (like Toasts or SnackBar) to inform users that they have successfully copied in Android 12L (API level 32) and earlier. For Android 13 and higher, we strongly advise uninstalling any pop-up widget displayed after an in-app copy to prevent information from being displayed again.

Coming back to the StatusBar Quick Settings Placement API, we have a lot more going here, after you add the desired functionality to your Android App, the user will be prompted to choose if they wish to add the displayed TileService to their current tiles after calling this. 

The system may cease handling requests for a specific ComponentName after a certain number of requests, and the user may reject the request. The user will see information about the tile as a result of the request:

  1. Name of the application 
  2. Tile label Icon

This is handled by the main UI thread, and is thus presented in a beautiful way to the user, and is also accompanied by an intuitive UI. The Context used to obtain this service determines the user for whom this will be added, and that user must match the one who is now logged in. You can use the code given below to add this functionality to your Android App, after that you can continue building it as you would normally do. Notice how there are [parameters for providing a proper name for the tile, an icon that will be placed in the User Quick Setting’s Panel to use, and a valid executor to be performed when the user clicks the app icon.

Java




public void requestAddTileService (ComponentName tileServiceComponentName, 
                CharSequence GeeksforGeeks, 
                Icon gfgIcon, 
                Executor addGfGTile, 
                Consumer<Integer> resultCallback)


The TileService needs to be exported and the requesting application needs to be in the foreground (ActivityManager.RunningAppProcessInfo#IMPORTANCE FOREGROUND). It should be noted that the system may decide to automatically reject a request if the user has previously rejected it enough times (user, ComponentName).

Particulars

Description

tileServiceComponentName ComponentName: The TileService’s component name for the request. This value can’t be empty.
resultExecutor  A callback executor that can be used This value can’t be empty.
icon Icon to use in the user-viewed tile. This value can’t be empty.
tileLabel CharSequence: The label for the tile that the user will see. This value can’t be empty.
resultCallback To signal the RequestResult callback. This value can’t be empty.

Conclusion 

That’s it, this is how easy it is to create custom QS Tiles for your app, they are a great way to provide shortcuts to deep app actions directly from a person’s lock screen, as they will directly have access to it. This paired with the amazing keyboard copy-paste service API makes day-to-day tasks intuitive.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads