Warum werden meine Kontaktfotos nicht in der Listenansicht angezeigt?

WICHTIG ZU BEACHTEN, DASS DIE API, MIT DER IM ARBEITET, 2.3 IST

Ich habe eine Listenansicht, die derzeit von den Kontakten (derzeit 6) ausgefüllt wird, die mir Textnachrichten im Posteingang meines Geräts gesendet haben. Nachdem alle Kontakte gesammelt und an einen weitergeleitet wurdenArrayList<String>wird die ArrayList dann an einen Konstruktor für my übergebenCustomAdapter Klasse. Von dort aus ist dies der Code, der meine Listenansicht mit den Kontakten aus meinem Posteingang aus meiner Liste fülltgetView() Methode:

holder.photo = (ImageView) rowView.findViewById(R.id.iv_contactPic);
holder.contact = (TextView) rowView
                .findViewById(R.id.contactEntryText);

String folder = "content://sms/inbox/";
        Uri mSmsQueryUri = Uri.parse(folder);
        contactID = new ArrayList<String>();

        try {
            c = context.getContentResolver().query(mSmsQueryUri,
                    new String[] { "_id", "address", "date", "body" },
                    null, null, null);
            if (c == null) {
                Log.i(TAG, "cursor is null. uri: " + mSmsQueryUri);
            }

                c.moveToFirst();
                while (c.moveToNext()) {

                cid = c.getString(0);
                contactID.add(cid); // stores contact IDs
            }

        } catch (Exception e) {
            //Log.e(TAG, e.getMessage());
        } finally {
            c.close();
        }

if(holder != null){
    holder.contact.setText(data.get(position)); // displays contact by name

    //Contact photo not showing
    holder.photo.setImageBitmap(getByteContactPhoto(contactID.get(position));
}

Aus dem obigen Code,holder.contact zeigt 6 Kontakte ohne Problem an. Aber das Problem ist mitholder.photo die überhaupt nichts anzeigt. Hier ist die Methode, die angenommen wird, um die Fotos zu erhalten:

public Bitmap getByteContactPhoto(String contactId) {
    Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, Long.parseLong(contactId));
    Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
    Cursor cursor = context.getContentResolver().query(photoUri,
                    new String[] {Contacts.Photo.DATA15}, null, null, null);
    if (cursor == null) {
        return null;
    }
    try {
                cursor.moveToFirst();
        if (cursor.moveToNext()) {
            byte[] data = cursor.getBlob(0);
            if (data != null) {
                return BitmapFactory.decodeStream( new ByteArrayInputStream(data));
            }
        }
    } finally {
        cursor.close();
    }
    return null;
    }

In LogCat ist dies jedoch das einzige, was in Bezug auf die Fotos angezeigt wird:

W/Resources(15031): Converting to string: TypedValue{t=0x12/d=0x0 a=3 r=0x7f080015}
W/Resources(15031): Converting to string: TypedValue{t=0x12/d=0x0 a=3 r=0x7f080015}
W/Resources(15031): Converting to string: TypedValue{t=0x12/d=0x0 a=3 r=0x7f080015}
W/Resources(15031): Converting to string: TypedValue{t=0x12/d=0x0 a=3 r=0x7f080015}
W/Resources(15031): Converting to string: TypedValue{t=0x12/d=0x0 a=3 r=0x7f080015}
W/Resources(15031): Converting to string: TypedValue{t=0x12/d=0x0 a=3 r=0x7f080015}

Irgendwelche Ideen, um dies zu beheben, damit die Kontaktfotos angezeigt werden?

Antworten auf die Frage(0)

Ihre Antwort auf die Frage