In android development, the phase comes where the app needs specific settings to be modified manually by the user. So at that time developer directs the user to open specific settings and modify them. So in this article, it has been discussed how to open specific settings and make the user change them easily.
Step 1: Create a new Empty Activity android project
- While creating a new android studio project give the name of the project as “Open specific settings”.
- You may refer: Android | How to Create/Start a New Project in Android Studio?
- Select Kotlin as the language, and layout name as activity_main.xml.
Step 2: You may change the color combination of the application
- You may change the color combination of the base theme of the application. To change it open app -> src -> main -> res -> values -> colors.xml.
- Invoke the following code in colors.xml.
XML
<?xml version="1.0" encoding="utf-8"?><resources> <color name="colorPrimary">#0f9d58</color> <color name="colorPrimaryDark">#006d2d</color> <color name="colorAccent">#55cf86</color></resources> |
- You may refer to the following image to get the colors.xml file.

Step 3: Working with the activity_main.xml
- Here, Buttons are used to open each of the specific settings. There are many different settings in android out of all of the seven that are most commonly used. So seven buttons are added to the activity layout.
- Invoke the following code inside activity_main.xml:
XML
<?xml version="1.0" encoding="utf-8"?><LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" tools:ignore="HardcodedText"> <!--Make sure to give appropriate IDs to all buttons so that can be easily handled--> <!--Button to open wireless settings--> <Button android:id="@+id/wireless_settings" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" android:backgroundTint="@color/colorPrimary" android:text="Open Wireless Settings" android:textColor="@android:color/white" /> <!--Button to open wifi settings--> <Button android:id="@+id/wifi_settings" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" android:backgroundTint="@color/colorPrimary" android:text="Open Wi-Fi Settings" android:textColor="@android:color/white" /> <!--Button to open bluetooth settings--> <Button android:id="@+id/bluetooth_settings" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" android:backgroundTint="@color/colorPrimary" android:text="Open Bluetooth Settings" android:textColor="@android:color/white" /> <!--Button to open date settings--> <Button android:id="@+id/date_settings" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" android:backgroundTint="@color/colorPrimary" android:text="Open Date Settings" android:textColor="@android:color/white" /> <!--Button to open input method settings--> <Button android:id="@+id/input_method_settings" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" android:backgroundTint="@color/colorPrimary" android:text="Open Input Method Settings" android:textColor="@android:color/white" /> <!--Button to open display settings--> <Button android:id="@+id/display_settings" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" android:backgroundTint="@color/colorPrimary" android:text="Open Display Settings" android:textColor="@android:color/white" /> <!--Button to open Location settings--> <Button android:id="@+id/location_settings" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" android:backgroundTint="@color/colorPrimary" android:text="Open Location Settings" android:textColor="@android:color/white" /></LinearLayout> |
The following output UI is produced:

Step 4: Working with the MainActivity.kt file
- You may refer: Buttons in Kotlin to know how to handle the button clicks through setOnClickListener using Kotlin.
- In this case, implicit intents are used you may refer: Android | Implicit and Explicit Intents with Examples for implicit intents.
- Invoke the following code to handle all the buttons.
Kotlin
import android.content.Intent import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.provider.Settings.*import android.view.View import kotlinx.android.synthetic.main.activity_main.*class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) // Handle wireless settings button wireless_settings?.setOnClickListener(View.OnClickListener{ val i = Intent(ACTION_WIRELESS_SETTINGS) startActivity(i) }) // Handle wifi settings button wifi_settings?.setOnClickListener(View.OnClickListener{ val i = Intent(ACTION_WIFI_SETTINGS) startActivity(i) }) // Handle bluetooth settings button bluetooth_settings?.setOnClickListener(View.OnClickListener{ val i = Intent(ACTION_BLUETOOTH_SETTINGS) startActivity(i) }) // Handle date settings button date_settings?.setOnClickListener(View.OnClickListener{ val i = Intent(ACTION_DATE_SETTINGS) startActivity(i) }) // Handle input method settings button input_method_settings?.setOnClickListener(View.OnClickListener{ val i = Intent(ACTION_INPUT_METHOD_SETTINGS) startActivity(i) }) // Handle display settings button display_settings?.setOnClickListener(View.OnClickListener{ val i = Intent(ACTION_DISPLAY_SETTINGS) startActivity(i) }) // Handle location settings button location_settings?.setOnClickListener(View.OnClickListener{ val i = Intent(ACTION_LOCATION_SOURCE_SETTINGS) startActivity(i) }) }} |
Note: Make sure to import the android.provider.Settings package to import all the settings class in the project:
import android.provider.Settings.*
Output: Run on Emulator
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- How to Add OpenCV library into Android Application using Android Studio?
- Android | Android Application File Structure
- Android | How to add Radio Buttons in an Android Application?
- Android | How to Request permissions in Android Application?
- Android | How to open Camera through Intent and display captured image
- How to open dialer in Android through Intent?
- Components of an Android Application
- The Application Manifest File | Android
- How to add a Pie Chart into an Android Application
- How to add Toggle Button in an Android Application
- How to Add Widget of an Android Application?
- Designing the Landscape and Portrait Mode of Application in Android
- Processes and Application Lifecycle in Android
- How to install Android Applications in Mobile Phone without USB Cables using Android Studio
- How to find and open the Hidden files in a Directory using Java
- Android | AdMob Interstitial Ads for Android Studio
- Android | How to Create/Start a New Project in Android Studio?
- Android | Running your first Android app
- Difference between Android 1.1 and Android 4.0.1
- Difference between Android 1.1 and Android 2.3.4
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : adityamshidlyali

