Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
461 views
in Technique[技术] by (71.8m points)

phone call - Android dialer application

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.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...