Make Call in Android Application using default call application
For a generic use, you can implement like below.
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + "1111111111"));
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PackageManager packageManager = context.getPackageManager();
List activities = packageManager.queryIntentActivities(callIntent, PackageManager.MATCH_DEFAULT_ONLY);
for(int j = 0 ; j < activities.size() ; j++)
{
if(activities.get(j).toString().toLowerCase().contains("com.android.phone"))
{
callIntent.setPackage("com.android.phone");
}
else if(activities.get(j).toString().toLowerCase().contains("call"))
{
String pack = (activities.get(j).toString().split("[ ]")[1].split("[/]")[0]);
callIntent.setPackage(pack);
}
}
context.startActivity(callIntent);
Also you have to add this intent-filter to activity or receiver etc. in AndroidManifest.xml
<activity>
<intent-filter>
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<data android:scheme="tel" />
</intent-filter>
</activity>
Finally don't forget to add permission to AndroidManifest.xml
<uses-permission android:name="android.permission.CALL_PHONE" />
Use intent.setPackage("com.android.phone");
Like
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setPackage("com.android.phone");
intent.setData(Uri.parse("tel:9898989898"));
startActivity(intent);
But better is to let the user to choose.
Read more at How to call from Android Native Dialers, ignore other dialers