Answering my own question. I finally found a way to automatically open a vCard with the contacts app, thanks to this answer about explicit intents.
private void openBackup(File savedVCard)
{
try
{
String vcfMimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension("vcf");
Intent openVcfIntent = new Intent(Intent.ACTION_VIEW);
openVcfIntent.setDataAndType(Uri.fromFile(savedVCard), vcfMimeType);
// Try to explicitly specify activity in charge of opening the vCard so that the user doesn't have to choose
// https://stackoverflow.com/questions/6827407/how-to-customize-share-intent-in-android/9229654#9229654
try
{
if (getActivity().getPackageManager() != null)
{
List<ResolveInfo> resolveInfos = getActivity().getPackageManager().queryIntentActivities(openVcfIntent, 0);
if (resolveInfos != null)
{
for (ResolveInfo resolveInfo : resolveInfos)
{
ActivityInfo activityInfo = resolveInfo.activityInfo;
if (activityInfo != null)
{
String packageName = activityInfo.packageName;
String name = activityInfo.name;
// Find the needed Activity based on Android source files: http://grepcode.com/search?query=ImportVCardActivity&start=0&entity=type&n=
if (packageName != null && packageName.equals("com.android.contacts") && name != null && name.contains("ImportVCardActivity"))
{
openVcfIntent.setPackage(packageName);
break;
}
}
}
}
}
}
catch (Exception ignored)
{
}
startActivity(openVcfIntent);
}
catch (Exception exception)
{
// No app for openning .vcf files installed (unlikely)
}
}