CopyPastor

Detecting plagiarism made easy.

Score: 0.8062846064567566; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2018-06-11
by Shubham Mittal

Original Post

Original - Posted on 2015-06-10
by Sonia John Kavery



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Here is the working code:-
public static Bitmap retrieveContactPhoto(Context context, String number) { ContentResolver contentResolver = context.getContentResolver(); String contactId = null; Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number)); String[] projection = new String[]{ContactsContract.PhoneLookup.DISPLAY_NAME, ContactsContract.PhoneLookup._ID}; Cursor cursor = contentResolver.query( uri, projection, null, null, null); if (cursor != null) { while (cursor.moveToNext()) { contactId = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.PhoneLookup._ID)); } cursor.close(); } Bitmap photo = BitmapFactory.decodeResource(context.getResources(), R.drawable.about_icon_email); Uri contactUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.parseLong(contactId)); Uri photoUri = Uri.withAppendedPath(contactUri, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY); cursor = context.getContentResolver().query(photoUri, new String[]{ContactsContract.Contacts.Photo.PHOTO}, null, null, null); if (cursor == null) { return null; } try { if (cursor.moveToFirst()) { byte[] data = cursor.getBlob(0); if (data != null) { return BitmapFactory.decodeStream( new ByteArrayInputStream(data)); } } } finally { cursor.close(); } return null; }
Hope it will help you
public static Bitmap retrieveContactPhoto(Context context, String number) { ContentResolver contentResolver = context.getContentResolver(); String contactId = null; Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number)); String[] projection = new String[]{ContactsContract.PhoneLookup.DISPLAY_NAME, ContactsContract.PhoneLookup._ID}; Cursor cursor = contentResolver.query( uri, projection, null, null, null); if (cursor != null) { while (cursor.moveToNext()) { contactId = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.PhoneLookup._ID)); } cursor.close(); } Bitmap photo = BitmapFactory.decodeResource(context.getResources(), R.drawable.default_image); try { InputStream inputStream = ContactsContract.Contacts.openContactPhotoInputStream(context.getContentResolver(), ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, new Long(contactId))); if (inputStream != null) { photo = BitmapFactory.decodeStream(inputStream); } assert inputStream != null; inputStream.close(); } catch (IOException e) { e.printStackTrace(); } return photo; }

        
Present in both answers; Present only in the new answer; Present only in the old answer;