Birju Vachhani
Birju Vachhani

Reputation: 6353

How to open Settings panel in Android Q programmatically?

As per Android Q new features, there is a inline settings panel showing key connectivity settings that lets the user modify different connectivity settings such as airplane mode, wifi, volume, NFC and internet connectivity.

How can I open that settings panel programmatically from my app? like in screenshot below.

enter image description here

Upvotes: 7

Views: 9745

Answers (1)

Birju Vachhani
Birju Vachhani

Reputation: 6353

This is very simple and easy to implement using Settings panel API available in Android Q.

Simple we need to trigger intent with one of the new Settings.Panel actions.

To open Internet Connectivity Panel:

enter image description here

Java:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
    Intent panelIntent = new Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY)
    startActivityForResult(panelIntent, 545)
}

Kotlin:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
    val panelIntent = Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY)
    startActivityForResult(panelIntent, 545)
}


To open Volume control panel:

enter image description here

Java:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
    Intent panelIntent = new Intent(Settings.Panel.ACTION_VOLUME)
    startActivityForResult(panelIntent, 545)
}

Kotlin:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
    val panelIntent = Intent(Settings.Panel.ACTION_VOLUME)
    startActivityForResult(panelIntent, 545)
}


To open WIFI panel:

enter image description here

Java:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
    Intent panelIntent = new Intent(Settings.Panel.ACTION_WIFI)
    startActivityForResult(panelIntent, 545)
}

Kotlin:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
    val panelIntent = Intent(Settings.Panel.ACTION_WIFI)
    startActivityForResult(panelIntent, 545)
}


To open NFC panel:

enter image description here

Java:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
    Intent panelIntent = new Intent(Settings.Panel.ACTION_NFC)
    startActivityForResult(panelIntent, 545)
}

Kotlin:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
    val panelIntent = Intent(Settings.Panel.ACTION_NFC)
    startActivityForResult(panelIntent, 545)
}

Here you can check more about settings panel from Android official doc:

1) https://developer.android.com/preview/features#settings-panels

2) https://developer.android.com/reference/android/provider/Settings.Panel

Upvotes: 22

Related Questions