I am figuring out a way to replace the default dialer application from my custom dialer application, but I am not getting how to achieve this.

Here is what I want

  • Create a custom dialer UI
  • My application is called whenever call button hardware or that one in Android is pressed
  • The application can also be called from the contact screen

I am referring to public static final String ACTION_DIAL.

Solution 1

  1. Create a simple Android application (our dialer). To actually call someone, you just need that method:

    private void performDial(String numberString) {
        if (!numberString.equals("")) {
           Uri number = Uri.parse("tel:" + numberString);
           Intent dial = new Intent(Intent.ACTION_CALL, number);
  2. Give your application permission to call in AndroidManifest

    <uses-permission android:name="android.permission.CALL_PHONE" />
  3. Set in AndroidManifest intention that says to your phone to use your app when need a dialer

When someone press the call button:

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

When someone fire an URI:

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

Solution 2

This worked for me:

        android:label="@string/app_name" >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />

        <!-- open activity when establishing a call -->
            <action android:name="android.intent.action.CALL_PRIVILEGED" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="tel" />


Solution 3

Refer to this answer by arekolek.

This is the correct way to extend an InCallService by a third-party app, that will replace the system default dialer and InCallScreen after the user accepts the prompt at startup.

He also provides a working sample app in Kotlin (bonus points).

Please upvote his answer there, I do not deserve credit for his work.

Note: will only work for API 23+, and might need extra permissions in API 26

Solution 4

The ACTION_DIAL intent appears to allow you to pass a number to call to the standard dialer, ready for the user to call it, if they wish to do so, so isn't what you need.

Do you have a specific question, or are you looking for someone to tell you how to implement your app being called when the software/hardware call button is pressed?

Looks like you need ACTION_CALL_BUTTON - http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL_BUTTON