mangstadt/ez-vcard

Unable to share Vcf contact card for Android 11 and above.

Closed this issue · 1 comments

Hi, I am unable to share a contact from native to my android app. please help here.

public static File createVcardFile(VCard vCard) {

    File filePath = FileUtils.getFilesFolder(); **// /storage/emulated/0/xyz/xyz files/**
    File file = new File(filePath, "ContactCard_" + System.currentTimeMillis() + ".vcf"); **// /storage/emulated/0/xyz/xyz files/ContactCard_1646212512605.vcf**

    VCardWriter writer = null;
    try {
        writer = new VCardWriter(file, VCardVersion.V4_0); **// null**
        writer.write(vCard);
    } catch (Exception e) {
        FileLogUtils.e(TAG, "createVcard(): " + e);
    } finally {
        if (writer != null) { // null
            try {
                writer.close();
            } catch (IOException e) {
                FileLogUtils.e(TAG, "createVcard(): " + e);
            }
        }
    }
    return file; **// returns file path**
}

// file path is returned but vcard is empty because writer is null