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.

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

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

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
    setPhoneDefault()
}

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 {
    putExtra(
        TelecomManager.EXTRA_CHANGE_DEFAULT_ IALER_PACKAGE_NAME,
packageName
    )
}, REQUEST_CODE_DE AULT_DIALER)

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.

if (requestCode == REQUEST_CODE_DEFAULT_DIALER) {
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

Mr Phone - Find The Next Best Phone You Want To Buy

Add Spacing to Recycler View Linear Layout Manager Using Item Decoration

Add Options Menu to Activity and Fragment

Create Assets Folder, Add Files and Read Data From It