Android Dialer Application

Android dialer application


  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>

Creating custom android dialer

Create an app that responds to Intent.ACTION_DIAL. In the AndroidManifest.xml you need to add the following to that Activity:

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

You can read more in:

Android dialer application

How to set my custom dialer app as default dialer in AOSP

The query logic has changed and it's in packages/services/Telecomm/src/com/android/server/telecom/DefaultDialerCache.java

Resources resources = mContext.getResources();
mSystemDialerComponentName = new ComponentName(resources.getString(
com.android.internal.R.string.config_defaultDialer),
resources.getString(R.string.incall_default_class));

You should modify or overlay

  1. config_defaultDialer in frameworks/base/core/res/res/values/config.xml
  2. incall_default_class in packages/services/Telecomm/res/values/config.xml
  3. dialer_default_class in packages/services/Telecomm/res/values/config.xml

Android get dialer package name

You can filter all dialer applications using Intent.ACTION_DIAL action and PackageManager.queryIntentActivities(...). Where it will return list of applications which can dial phone. Read more at Android: How to show a list of dialer app installed on my device instead of directly calling default dialer


You can use below code, as it is

public List<String> getPackagesOfDialerApps(Context context){

List<String> packageNames = new ArrayList<>();

// Declare action which target application listen to initiate phone call
final Intent intent = new Intent();
intent.setAction(Intent.ACTION_DIAL);
// Query for all those applications
List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentActivities(intent, 0);
// Read package name of all those applications
for(ResolveInfo resolveInfo : resolveInfos){
ActivityInfo activityInfo = resolveInfo.activityInfo;
packageNames.add(activityInfo.applicationInfo.packageName);
}

return packageNames;
}

change android dialer by intent

Use this piece of code in your manifest file to choose the user your application as a dialer

<activity
android:name="com.sample.MyDailer"
android:label="@string/mycall" >
<intent-filter>
<action android:name="android.intent.action.CALL" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<data android:scheme="tel" />
</intent-filter>



Related Topics



Leave a reply



Submit