Android development
mobile app
button click action
phone settings
Android tutorial

How do I open phone settings when a button is clicked?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

On Android, you cannot usually change system settings directly from a normal app, but you can send the user to the relevant Settings screen. The usual approach is to attach a click listener to a button and launch an Intent for either general device settings or a more specific settings page.

Opening the Main Settings Screen

If you want the user to land on the top-level Settings app, use Settings.ACTION_SETTINGS.

kotlin
1import android.content.Intent
2import android.os.Bundle
3import android.provider.Settings
4import android.widget.Button
5import androidx.appcompat.app.AppCompatActivity
6
7class MainActivity : AppCompatActivity() {
8    override fun onCreate(savedInstanceState: Bundle?) {
9        super.onCreate(savedInstanceState)
10        setContentView(R.layout.activity_main)
11
12        val button = findViewById<Button>(R.id.openSettingsButton)
13        button.setOnClickListener {
14            val intent = Intent(Settings.ACTION_SETTINGS)
15            startActivity(intent)
16        }
17    }
18}

This is the broadest option. It is useful when you only need to get the user into system settings and do not care about a specific destination.

Opening a More Specific Settings Screen

Often, a targeted screen creates a better user experience. Android exposes many settings actions, such as Wi-Fi, location, and application details.

kotlin
val intent = Intent(Settings.ACTION_WIFI_SETTINGS)
startActivity(intent)

For permission-related flows, the most common destination is your app's own settings page:

kotlin
1import android.content.Intent
2import android.net.Uri
3import android.provider.Settings
4
5val intent = Intent(
6    Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
7    Uri.fromParts("package", packageName, null)
8)
9startActivity(intent)

That is the screen users open when they need to enable a denied permission manually after selecting "Don't ask again" or when they need to review notifications, storage, or battery settings for your app.

Connecting the Intent to a Button

The button itself is not special. The important part is to keep the click flow clear for the user. If the app needs location access, the button label should say something like "Open app settings" rather than a vague "Continue".

In a Fragment, the code is almost identical:

kotlin
1binding.openSettingsButton.setOnClickListener {
2    val intent = Intent(
3        Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
4        Uri.fromParts("package", requireContext().packageName, null)
5    )
6    startActivity(intent)
7}

This pattern is common in permission help screens shown after a denial.

Handle Unsupported Destinations Carefully

Many settings actions are standard, but some device vendors customize Settings behavior. It is a good idea to wrap the launch in a small safety check.

kotlin
1val intent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
2if (intent.resolveActivity(packageManager) != null) {
3    startActivity(intent)
4}

That protects your app from crashing if a specific settings activity is unavailable.

What You Cannot Do

Launching Settings does not guarantee that the user will enable anything. Your app should check the relevant state again when the user returns. For example, after sending the user to location settings, verify whether location access is now available instead of assuming success.

Also remember that most protected settings cannot be toggled silently by third-party apps. The operating system deliberately keeps the user in control.

Common Pitfalls

Opening the general Settings screen when the real need is app-specific permissions creates unnecessary friction for the user.

Assuming the setting changed after startActivity is a logic error. Always re-check the device or permission state.

Forgetting to explain why the user is being sent to Settings leads to abandonment because the flow feels abrupt.

Some settings actions vary by device vendor or Android version, so guard against unavailable targets when possible.

Trying to change protected settings directly from a normal app will usually fail because Android restricts that behavior.

Summary

  • Use a button click listener to launch a settings Intent.
  • 'Settings.ACTION_SETTINGS opens the main Settings screen.'
  • More targeted actions such as ACTION_WIFI_SETTINGS or app details usually give a better experience.
  • Re-check the relevant permission or device state after the user returns.
  • Treat Settings launches as user guidance, not as a guaranteed state change.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.