32

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
ingsaurabh
  • 15,249
  • 7
  • 52
  • 81

4 Answers4

48
  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);
           startActivity(dial);
        }
    }
    
  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:

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

When someone fire an URI:

    <intent-filter>
        <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" />
    </intent-filter>
zirael
  • 1,137
  • 10
  • 21
  • Hi thanks for your reply its really great I got what I want but my app only opens when when I use hardware call button but if I use android softkey for making call its not working – ingsaurabh Feb 17 '11 at 13:22
  • 3
    If your phone ui (ie. htc sense) starts its own dialer instead of fire dialer activity then there's really nothing you could do... – zirael Feb 17 '11 at 13:39
  • thanks one more thing when I use dialer first time android asks me to choose between default dialer and my app how can I surpass this so that automatically my dialer is accepted without user interaction – ingsaurabh Feb 18 '11 at 04:43
  • 1
    You can't. At least for my knowledge. – zirael Feb 18 '11 at 11:11
  • 1
    If you see contacts application code, you will see android.intent.action.CALL_PRIVILEGED is used. Also refer http://stackoverflow.com/questions/4293864/how-to-include-my-application-as-a-dialing-option-when-calling-from-the-addressb – Vamsi Jan 17 '12 at 04:59
  • When dialing from a 3rd-party contacts app, I need to do action.CALL instead of action.DIAL for my app to show up on the list. Not even this works, however, when calling a number using the default contacts list or recent call list. If I do CALL_PRIVILEGED, all works (this is what skype does). The confusing thing for me, though, is that a google blog post highly discourages the use of CALL_PRIVILEGED. But, I see no other way. Post here: http://android-developers.blogspot.com/2013/05/handling-phone-call-requests-right-way.html – gdw2 Sep 20 '13 at 16:27
  • how do you design the layout. any guide on that ? – Sagar Nayak Apr 02 '16 at 10:30
  • This is not working if you wanted to create own dialler application. This is simply to redirect your call to native/available app. Any idea how to mark your application as dialler application ? CALL_PRIVILEGED seems one thing but that is also not working !! Any suggestion ! – CoDe Nov 02 '17 at 12:53
  • it's not a dialer app, it will use default app to call – user924 Apr 05 '18 at 18:15
  • How can I prevent the dialer from prompting my app? I just want incoming calls to be allowed – elcapitan Jun 17 '20 at 13:46
  • Then how to get the number clicked..? I mean when someone click a number from other app, then choose to open with our app, then how to get the number to show on my own app..? – ardan7779 Nov 25 '20 at 15:54
7

This worked for me:

        <activity
        android:name=".activities.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

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

    </activity>
Asaf Pinhassi
  • 15,177
  • 12
  • 106
  • 130
  • 1
    As I commented under another answer, this works for me. I think its weird, though, that Google discouraged using this intent in a recent blog post: http://android-developers.blogspot.com/2013/05/handling-phone-call-requests-right-way.html . If I follow their suggestion by using NEW_OUTGOING_CALL, my app doesn't show up alongside other apps, such as Skype, as an option for calls when making calls from the contacts app. Also, they claim that CALL_PRIVILEGED is available only for system apps. – gdw2 Sep 20 '13 at 16:33
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

leRobot
  • 1,497
  • 1
  • 18
  • 30
2

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

David Precious
  • 6,544
  • 1
  • 24
  • 31
  • yeah all I want is create a custom dialer I have used android.intent.action.CALL_BUTTON this only but its not working for me – ingsaurabh Feb 17 '11 at 13:08
  • Saurabh, did you able to resolve the issue? Share the solution so that community can be benefited. – Roll no1 Dec 01 '11 at 17:50
  • @ingsaurabh:pl share the answer if you found the solution. – Basher51 Apr 28 '14 at 10:53
  • I was able to overlay a view on top of the native dialer app.For more see : http://stackoverflow.com/questions/23701879/popup-window-on-incoming-call-screen-like-truecaller/24377603#24377603 – Basher51 Jun 24 '14 at 03:06