Skip to content
Related Articles
Open in App
Not now

Related Articles

How to Use Quick Settings Placement API in Android 13?

Improve Article
Save Article
  • Last Updated : 03 Feb, 2023
Improve Article
Save Article

Quick Settings tile is a quick setting that is present in the android device notification bar from where we can easily enable and disable the device or app settings such as Bluetooth or wifi. In this article, we will take a look at How to add a Quick Tile to our android device using Quick Settings Placement API. 

Step-By-Step Implementation

Step 1: Create a New Project in Android Studio

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Kotlin as the programming language.

Step 2: Updating SDK version in build.gradle file.

Navigate to Gradle Scripts>module level build.gradle file and add change compile SDK and target SDK to 33. After that simply sync your project to install it.

Step 3: Working with activity_main.xml.

Navigate to app>res>layout>activity_main.xml and add the below code to it. Comments are added in the code to get to know in detail. 


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""
    <!--creating button on add quick tile settings-->
        android:text="Add quick tile"
        app:backgroundTint="@color/edt_back_color" />

Step 4: Create a new class for AppTileService. 

Navigate to app>java>your app’s package name > Right click on it > New > Java/Kotlin class and name it as AppTileService and add the below code to it. Comments are added in the code to get to know it in detail. 


import android.content.Intent
import android.os.Build
import android.service.quicksettings.Tile
import android.service.quicksettings.TileService
import androidx.annotation.RequiresApi
class AppTileService : TileService() {
    // adding on start listening for tile service on below line.
    override fun onStartListening() {
        // on below line adding method to apply for tile.
        qsTile?.apply {
            state = Tile.STATE_ACTIVE
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                subtitle = "Open App"
            // on below line calling method to update tile.
    override fun onClick() {
        // on below line opening our apps main activity on clicking on the tile.

Step 5: Working with MainActivity.kt file.

Navigate to app>java>your app’s package name>MainActivity.kt file and add the below code to it. Comments are added in the code to get to know it in detail. 


import android.R.attr
import android.annotation.SuppressLint
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.provider.MediaStore
import android.widget.Button
import android.widget.ImageView
import android.widget.Toast
class MainActivity : AppCompatActivity() {
    // creating variables on below line.
    lateinit var quickTileBtn: Button
    override fun onCreate(savedInstanceState: Bundle?) {
        // initializing variables on below line.
        quickTileBtn = findViewById(
        // adding click listener for button on below line.
        quickTileBtn.setOnClickListener {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
                // initializing status bar manager on below line.
                val statusBarManager =
                    getSystemService(Context.STATUS_BAR_SERVICE) as StatusBarManager
                // adding request and tile service for status bar manager on below line.
                    // adding app's package components on below line.
                    // adding app name on below line.
                    // adding app icon on below line.
                    Icon.createWithResource(this, R.mipmap.ic_launcher),
            } else {
                // on below line displaying toast message.
                Toast.makeText(this, "`requestAddTileService` can only be called in Android 13/Tiramisu.",Toast.LENGTH_SHORT,).show()


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!