How to Get Current Default Language of Android Device Programmatically? Last Updated : 06 Oct, 2021 Comments Improve Suggest changes Like Article Like Report Smartphones seem to be predicting and showing us results from what we think in our minds. If you think of traveling, you shall soon expect something related to it in your device's feed. This is the next level of technology, where data helps in developing businesses. The software collects personal data like recent searches, device location, etc., to generate the feed. An important factor contributing to personal data is the device's default language, and it helps better understand the device's location. So, business in multiple ways provides various services and information available in that location to the user. In this article, we shall focus on fetching the default language of the device. 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. We demonstrated the application in Kotlin, so make sure you select Kotlin as the primary language while creating a New Project. Step 2: Working with the activity_main.xml file Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file. Add a Button in the layout file. XML <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <!--This button on click will generate a Toast message displaying default language--> <Button android:id="@+id/btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="click"/> </RelativeLayout> Step 3: Working with the MainActivity.kt file Go to the MainActivity.kt file and refer to the following code. Below is the code for the MainActivity.kt file. Comments are added inside the code to understand the code in more detail. Kotlin import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.Button import android.widget.Toast import java.util.* class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) // Declaring button from the layout val mButton = findViewById<Button>(R.id.btn) // When button is clicked, a Toast message is // displayed showing the current default language mButton.setOnClickListener { Toast.makeText(applicationContext, Locale.getDefault().language.toString(), Toast.LENGTH_SHORT).show() } } } Output: Comment More infoAdvertise with us Next Article How to Get Current Default Language of Android Device Programmatically? aashaypawar Follow Improve Article Tags : Kotlin Android Similar Reads How to Get the MAC of an Android Device Programmatically? MAC stands for Media Access Control. The MAC address is also known as the Equipment Id Number. This MAC Address is provided by the Network Interface Card. In this article, we will see step by step from creating a new empty project to How to make an android app to display MAC Address using Java. Note 2 min read How to Fetch Device ID in Android Programmatically? The android Device ID is a unique code, string combinations of alphabets and numbers, given to every manufactured android device. This code is used to identify and track each android device present in the world. In Android, the Device ID is typically related to the Google Play Services and is most c 3 min read How to Find Out Carrier's Name in Android Programmatically? In this article we will see how to retrieve the carrier name on Android device. This information can be useful for applications that need to provide specific functionality based on the user's cellular network provider. A sample video is given below to get an idea about what we are going to do in thi 3 min read How to Change the Whole App Language in Android Programmatically? Android 7.0(API level 24) provides support for multilingual users, allowing the users to select multiple locales in the setting. A Locale object represents a specific geographical, political, or cultural region. Operations that require these Locale to perform a task are called locale-sensitive and u 5 min read How to Change Input Type of EditText Programmatically in Android? EditText in Android UI or applications is an input field, that is used to give input text to the application. This input text can be of multiple types like text (Characters), number (Integers), etc. These fields can be used to take text input from the users to perform any desired operation. Let us s 3 min read How to Programmatically Enable/Disable Bluetooth in Android? In Android Phone, it is very much easy to enable/disable Bluetooth by using the Bluetooth icon, but have you wondered how to do this task programmatically in Android. A sample GIF is given below to get an idea about what we are going to do in this article. Note that we are going to implement this pr 3 min read How to Get the Device's IMEI and ESN Programmatically in Android? Many times while building Android Applications we require a unique identifier to identify the specific mobile users. For identifying that user we use a unique address or identity. For generating that unique identity we can use the android device id. In this article, we will take a look at How to get 4 min read How to Fetch Currently Running Tasks in Android Programmatically? Android devices run several tasks in the background for providing a seamless experience to the users. Importantly, tracking background and foreground usages is important as it directly impacts the battery life and static memory, i.e. RAM. One can enable the developer option in the settings to track 2 min read How to Detect Tablet or Phone in Android Programmatically? A Mobile is a portable electronic device that allows you to make calls, send messages, and access the internet, among other functions. A tablet is a mobile computing device with a touchscreen display and typically a larger screen size than a smartphone. Both devices are designed to be portable and a 3 min read How to Get RAM Memory in Android Programmatically? RAM (Random Access Memory) of a device is a system that is used to store data or information for immediate use by any application that runs on the device. Every electronic device that runs a program as a part of its application has some amount of RAM associated with it. Mobile devices nowadays come 3 min read Like