Android的拨号器应用程序应用程序、拨号器、Android

2023-09-11 12:00:09 作者:被温柔宠坏

我找出一个办法来取代从我的自定义拨号器应用程序默认的拨号器应用程序,但我没有得到如何实现这一点。

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.

下面是我想要的。

创建一个自定义的拨号界面 在我的应用程序时,要调用呼叫按钮硬件或一个在Android是pressed 在该应用程序也可以从联系人屏幕名为

我指的是* 公共静态最后弦乐ACTION_DIAL *。

推荐答案

这是一种复杂的问题,但是......

It's kind of complex question but....

创建一个简单的Andr​​oid应用程序(我们的拨号器)。要真正叫人,你只需要一个方法:

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);
    }
}

为您的应用程序许可AndroidManifest叫

Give your application permission to call in AndroidManifest

<uses-permission android:name="android.permission.CALL_PHONE" />

坐落在AndroidManifest的意图,说你的电话的时候需要一个拨号器使用你的应用程序

Android程序开发 简单电话拨号器

Set in AndroidManifest intention that says to your phone to use your app when need a dialer

当有人preSS呼叫按钮:

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>

当有人触发一个URI:

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>