Android dialer application
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);
}
}Give your application permission to call in AndroidManifest
<uses-permission android:name="android.permission.CALL_PHONE" />
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
- config_defaultDialer in frameworks/base/core/res/res/values/config.xml
- incall_default_class in packages/services/Telecomm/res/values/config.xml
- 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
Firebase Analytics Custom Events Params
Android:Loading an Image from the Web with Asynctask
Unsupportedoperationexception: Can't Convert to Dimension: Type=0X1
How to Put Multiple Project_Number/Sender Id in Google-Services.JSON
The Completest Cocos2D-X Tutorial & Guide List
How to Put a Border Around an Android Textview
How to Create a Listview with Rounded Corners in Android
How to Set Different Label for Launcher Rather Than Activity Title
How to Implement Drawerarrowtoggle from Android Appcompat V7 21 Library
This Version of the Application Is Not Configured for Billing Through Google Play
Android Preventing Double Click on a Button
How to Use the Simple Http Client in Android
Should We Use Recyclerview to Replace Listview
Android Arraylist of Custom Objects - Save to Sharedpreferences - Serializable