2011-02-17 48 views
30

我想出了一种方法来从我的自定义拨号器应用程序中替换默认的拨号器应用程序,但我没有得到如何实现这一点。Android拨号器应用程序

这里是我想

  • 创建一个自定义的拨号程序UI什么
  • 我的应用程序被称为每当呼叫按钮的硬件或一个Android中按下
  • 应用程序也可以从联系人叫屏幕

我指的是public static final String ACTION_DIAL

+0

在这里你可以找到一个自定义的拨号程序:https://github.com/Ali-Rezaei/PadLayout – Ali 2017-12-27 11:59:42

回答

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

    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. 给你的应用程序的权限在AndroidManifest调用

    <uses-permission android:name="android.permission.CALL_PHONE" /> 
    
  3. 坐落在AndroidManifest原意是说你的手机使用你的应用程序时需要拨号

当有人按下通话键:

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

当有人触发一个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> 
2

ACTION_DIAL intent似乎允许您传递一个号码来呼叫标准拨号程序,准备好让用户调用它,如果他们希望这样做,那么不是您所需要的。

您是否有具体问题,或者您是否在寻找某人告诉您如何在按下软件/硬件调用按钮时实现您的应用程序?

看起来像你需要ACTION_CALL_BUTTON - http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL_BUTTON

+0

是所有我想要的是创建一个自定义拨号器我已经使用android.intent.action.CALL_BUTTON这只,但它不为我工作 – ingsaurabh 2011-02-17 13:08:46

+0

Saurabh,你能解决这个问题吗?分享解决方案,让社区受益。 – 2011-12-01 17:50:31

+0

@ingsaurabh:pl如果找到解决方案,请分享答案。 – Basher51 2014-04-28 10:53:35

7

这为我工作:

 <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> 
相关问题