Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;

public class Main {
    /**
     * Decode byte array to drawable object
     *
     * @param context Context to obtain {@link android.content.res.Resources}
     * @param array   The source byte array
     * @return The drawable created from source byte array
     */
    public static Drawable getDrawableFromByteArray(Context context, byte[] array) {
        if (array == null) {
            return null;
        }
        Bitmap compass = BitmapFactory.decodeByteArray(array, 0, array.length);
        return new BitmapDrawable(context.getResources(), compass);
    }
}