Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.IOException;
import java.io.InputStream;

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

public class Main {
    private static Bitmap getBitmapFromAsset(Context context, String filePath) {
        AssetManager assetManager = context.getAssets();

        InputStream istream;
        Bitmap bitmap = null;
        try {
            istream = assetManager.open(filePath);
            bitmap = BitmapFactory.decodeStream(istream);
        } catch (IOException e) {
            // handle exception
        }

        return bitmap;
    }
}