1
當我簡單的查詢我的聯繫人,那麼所有的聯繫人顯示在列表中還包括Facebook聯繫人和Gmail聯繫人,但是當我使用這個代碼,那麼一些些名片是空白......沒有製作電子名片的Facebook聯繫人
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();
}
,我想,不要複製的代碼Vcard中的照片然後我該怎麼辦? – kamal 2013-03-11 06:33:53
先生其不工作請幫忙 – kamal 2013-03-11 07:18:23
請參閱http://stackoverflow.com/questions/15333022/donot-insert-image-source-code-when-making-vcard/ – lumos 2013-03-11 07:49:17