TextView.setInputType(EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

Posted by 천류성

Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;

String[] projection = new String[] {

String[] projection = new String[] { ContactsContract.CommonDataKinds.Phone.CONTACT_ID, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.PHOTO_ID, ContactsContract.Data.RAW_CONTACT_ID };

Cursor contactCursor = managedQuery(uri, projection, null, null, null);
사진 가져오기 
contactId = ContactsContract.CommonDataKinds.Phone.CONTACT_ID의 값

public Bitmap getPhoto(Long contactId) {
Uri contactPhotoUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
InputStream photoDataStream =                                             Contacts.openContactPhotoInputStream(getContentResolver(),contactPhotoUri); 
Bitmap photo = BitmapFactory.decodeStream(photoDataStream);
return photo;
}

연락처 사진 변경.
rawContactId = ContactsContract.CommonDataKinds.Phone.RAW_CONTACT_ID 의 값

public static void setContactPhoto(ContentResolver c, byte[] bytes, long rawContactId) {

ContentValues values = new ContentValues();
int photoRow = -1;
String where = ContactsContract.Data.RAW_CONTACT_ID + " = " + rawContactId + "                     AND " + ContactsContract.Data.MIMETYPE + "=='" +             ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE + "'";
Cursor cursor = c.query(ContactsContract.Data.CONTENT_URI, null, where, null, null);
int idIdx = cursor.getColumnIndexOrThrow(ContactsContract.Data._ID);
if (cursor.moveToFirst()) {
photoRow = cursor.getInt(idIdx);
}
cursor.close();

values.put(ContactsContract.Data.RAW_CONTACT_ID, rawContactId);
values.put(ContactsContract.Data.IS_SUPER_PRIMARY, 1);
values.put(ContactsContract.CommonDataKinds.Photo.PHOTO, bytes);
values.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE);
if (photoRow >= 0) {
c.update(ContactsContract.Data.CONTENT_URI, values, ContactsContract.Data._ID + " = " + photoRow, null);
} else {
c.insert(ContactsContract.Data.CONTENT_URI, values);
}

}

Posted by 천류성
이전버튼 1 ··· 4 5 6 7 8 9 10 이전버튼

블로그 이미지
.....
천류성

태그목록

공지사항

Yesterday2
Today0
Total15,639

달력

 « |  » 2018.10
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

최근에 달린 댓글

최근에 받은 트랙백

글 보관함


티스토리 툴바