You can check if the system has any activities that can receive the intent like so:
private void tryOpenDialer(String phoneNumber) {
if (TextUtils.isEmpty(phoneNumber)) {
// invalid input - return or throw IllegalArgumentException
return;
}
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
PackageManager pkgManager = getPackageManager();
List<ResolveInfo> activities = pkgManager.queryIntentActivities(intent, 0);
if (activities.size() > 0) {
context.startActivity(intent)
} else {
// if you want, pop up a toast or dialog telling the user there is
// nothing on the device to handle this action
}
}