Android Assets打开调用过程源码分析

一、Android读取Assets中图片并显示

private Bitmap getImageFromAssetsFile(String fileName)
{
    Bitmap image = null;
    AssetManager am = getResources().getAssets();
    if (am == null)
    {
        return null;
    }
    try
    {
        InputStream is = am.open(fileName);
        image = BitmapFactory.decodeStream(is);
        is.close();
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    return image;
}
首先是获取AssetManager,然后调用其函数open,打开对应的资源文件

二、open函数追朔(Java层)

继续阅读“Android Assets打开调用过程源码分析”