Android Bitmap Load getBitmap(String photoId)

Here you can find the source of getBitmap(String photoId)

Description

This method used to get Bitmap From photo id.

Parameter

Parameter Description
photoId represented photo id

Return

represented

Declaration

@SuppressWarnings("deprecation")
private static Bitmap getBitmap(String photoId) 

Method Source Code

//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;
    }
}

Related

  1. downloadImageToSd(String urlSource, String pathDest)
  2. downloadImageToSd(String urlSource, String pathDest, String referer)
  3. getResizedBitmap(Uri imageUri, Activity activity)
  4. downSampleBitmap(Uri uri, Activity act, Boolean needRotate)
  5. getBitmap(Context context, int resId)
  6. getBitmapFromAsset(String strName, Context context)
  7. getBitmapFromInternet(String strName)
  8. getBitmapFromUri(Context ctxt, Uri selectedImageURI)
  9. getBitmapFromUrl(String url)