Anzeigen des Kontaktfotos von photo_ID
Ich lasse den Benutzer einen Kontakt in meiner App auswählen und zeige ihn im Widget für den Startbildschirm an, aber das Foto wird nicht angezeigt und ich weiß nicht, was falsch ist.
So erhalte ich den Verweis auf das Foto:
...
Cursor c = null;
try {
c = getContentResolver().query(uri, new String[] {
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.TYPE,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.PHOTO_ID },
null, null, null);
if (c != null && c.moveToFirst()) {
String number = c.getString(0);
int type = c.getInt(1);
String name = c.getString(2);
int photo = c.getInt(3);
showSelectedNumber(type, number, name, photo);
}
}
So zeige ich es an:
public void showSelectedNumber(int type, String number, String name, int photo) {
mAppWidgetPrefix.setText(name);
pickedNumber.setText(number);
pickedPhoto.setImageResource(photo);
}
Warum funktioniert es nicht?