Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Field;

import android.graphics.Bitmap;

import android.util.Log;

public class Main {
    private static Field FILELD_NATIVE_ID = null;

    public static Bitmap LogCreate(String tag, Bitmap bitmap) {
        Log.d("DecodeUtils", "[BMP_CREATE][ID:" + getBitmapNativeId(bitmap) + "][" + tag + "]");
        return bitmap;
    }

    public static long getBitmapNativeId(Bitmap bitmap) {
        if (bitmap == null)
            return 0l;
        if (FILELD_NATIVE_ID == null) {
            try {
                FILELD_NATIVE_ID = Bitmap.class.getDeclaredField("mNativeBitmap");
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            }
        }

        if (FILELD_NATIVE_ID == null)
            return 0l;
        try {
            return FILELD_NATIVE_ID.getLong(bitmap);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return 0l;
    }
}