Android 不制作Facebook联系人的Vcard
当我简单查询我的联系人时,列表中显示的所有联系人也包括facebook联系人和Gmail联系人,但当我使用此代码时,一些vcard是空白的Android 不制作Facebook联系人的Vcard,android,Android,当我简单查询我的联系人时,列表中显示的所有联系人也包括facebook联系人和Gmail联系人,但当我使用此代码时,一些vcard是空白的 String VCard = ""; Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null, null, null); phones.move
String VCard = "";
Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null, null, null);
phones.moveToFirst();
pDialog.setMax(phones.getCount());
for(int i =0;i<phones.getCount();i++)
{
String lookupKey = phones.getString(phones.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey);
AssetFileDescriptor fd;
try
{
fd = getContentResolver().openAssetFileDescriptor(uri, "r");
FileInputStream fis = fd.createInputStream();
byte[] buf = new byte[(int) fd.getDeclaredLength()];
fis.read(buf);
VCard += new String(buf);
String y =String.valueOf(i);
publishProgress(y);
phones.moveToNext();
Log.d("Vcard", VCard);
}
catch (Exception e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
try {
FileOutputStream mFileOutputStream = new FileOutputStream(file, false);
mFileOutputStream.write(VCard.toString().getBytes());
mFileOutputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String VCard=“”;
游标phones=getContentResolver().query(ContactsContract.CommonDataTypes.Phone.CONTENT\u URI,null,null,null);
moveToFirst();
pDialog.setMax(phones.getCount());
对于(int i=0;icontacts contract.commonDataTypes.Phone.CONTENT_URI是电话的URI
您应该将其更改为android.provider.ContactsContract.Contacts.CONTENT\u URI
您将获得非emty的联系人vcard,我希望,不要在vcard中复制照片代码,然后我会怎么做?请参阅