How to Set an Android App as a Default Dialer

A default dialer is an application that handles the Phone calls on the device. Google made the provision for third-party applications to be a default phone handler from SDK 23 (6.0, Marshmallow version). In the article, we will learn about how to set our Android application as a default dialer.

1) Add the below intent filters under the activity tag in the AndroidManifest.xml.

    <action android:name="android.intent.action.DIAL"/>
    <category android:name="android.intent.category.DEFAULT"/>

    <action android:name="android.intent.action.DIAL"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:scheme="tel"/>

2) Check if our application is already a default dialer app using TelecomManager.

val telecomManager = getSystemService(Context.TELECOM_SERVICE) as TelecomManager
Log.d(TAG, "Default Package Name ${telecomManager.defaultDialerPackage}")
if (telecomManager.defaultDialerPackage == packageName) {
    Log.d(TAG, "App is already a default dialer")
} else {
    // Set the app as the default launcher for phone

3) If not, send an implicit intent notifying the system to set the current application as a default application for phone calls.

startActivityForResult(Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER).apply {

4) In the onActivityResult, we listen for the request code and the result code to determine whether the user has set our app as a default dialer or not.

Log.d(TAG, "Request Code: $requestCode")
    when (resultCode) {
        RESULT_OK -> Log.d(TAG, "User granted default dialer permission")
        RESULT_CANCELED -> Log.d(TAG, "User denied default dialer permission")
        else -> Log.d(TAG, "Result code: $resultCode")

Now, run the application and the end user will see a system dialog requesting them to set the application as a default dialer.

Once the user clicks set, the application is set as a default dialer. If our app was already set as a default dialer and the user opens the application after reinstallation then it is automatically set as a default dialer without asking the user for confirmation.

Disclaimer: The UI for the system dialog will vary based on the OEM (Original Equipment Manufacturer).

Popular posts from this blog

How to Read Metadata from AndriodManifest File

Add Spacing to Recycler View Linear Layout Manager Using Item Decoration

Translucent and Transparent Background for Activity

Add Options Menu to Activity and Fragment

Create Assets Folder, Add Files and Read Data From It