I am using following code to make a call from my android application:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.par
find all app with dial ability
fun getPackagesOfDialerApps(context: Context): List {
val packageNames = ArrayList()
// Declare action which target application listen to initiate phone call
val intent = Intent()
intent.action = Intent.ACTION_DIAL
// Query for all those applications
val resolveInfos = context.packageManager.queryIntentActivities(intent, 0)
// Read package name of all those applications
for (resolveInfo in resolveInfos) {
val activityInfo = resolveInfo.activityInfo
packageNames.add(activityInfo.applicationInfo.packageName)
}
return packageNames
}
call method
val callIntent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:02188888888"))
callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context?.let {
for(dialerApp in Utils.getPackagesOfDialerApps(it)){
val appPackageName= dialerApp.toLowerCase(Locale.ENGLISH)
if(appPackageName == "com.android.phone" ||
appPackageName == "com.android.server.telecom" ||
appPackageName == "com.samsung.android.contacts"){
callIntent.setPackage(appPackageName)
break
}
}
}
try {
startActivity(callIntent)
} catch (ex: ActivityNotFoundException){
callIntent.setPackage(null)
startActivity(callIntent)
}