Here you can find the source of getBitmap(String photoId)
Parameter | Description |
---|---|
photoId | represented photo id |
@SuppressWarnings("deprecation") private static Bitmap getBitmap(String photoId)
//package com.java2s; import android.app.Activity; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.provider.ContactsContract.CommonDataKinds.Photo; import android.provider.ContactsContract.Data; public class Main { public static Activity mSmartAndroidActivity; /**//from w ww. j av a2s.co m * This method used to get {@link Bitmap} From photo id. * * @param photoId * represented photo id * @return represented {@link Bitmap} */ @SuppressWarnings("deprecation") private static Bitmap getBitmap(String photoId) { final Cursor photo = mSmartAndroidActivity.managedQuery( Data.CONTENT_URI, new String[] { Photo.PHOTO }, Data._ID + "=?", new String[] { photoId }, null); final Bitmap photoBitmap; if (photo.moveToFirst()) { byte[] photoBlob = photo.getBlob(photo .getColumnIndex(Photo.PHOTO)); photoBitmap = BitmapFactory.decodeByteArray(photoBlob, 0, photoBlob.length); } else { photoBitmap = null; } photo.close(); return photoBitmap; } }