Convert Base64 string Bitmap using android.util.Base64 - Android android.graphics

Android examples for android.graphics:Bitmap Convert

Description

Convert Base64 string Bitmap using android.util.Base64

Demo Code

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;

public class Main {

  public static Bitmap convertBase64toBitmap(String base64String) {

    if (base64String != null && !base64String.equals("")) {

      byte[] imageData = Base64.decode(base64String, Base64.DEFAULT);
      return BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
    } else/*  w ww.j a  va  2s.  c o  m*/
      return null;
  }

}

Related Tutorials