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.annotation.TargetApi;
import android.content.Context;
import android.graphics.drawable.Drawable;

import static android.os.Build.VERSION_CODES.LOLLIPOP;

public class Main {
    @TargetApi(LOLLIPOP)
    public static Drawable getDrawable(Context context, int id) {
        if (isCompatible(LOLLIPOP)) {
            return context.getDrawable(id);
        } else {
            return context.getResources().getDrawable(id);
        }
    }

    public static boolean isCompatible(int apiLevel) {
        return android.os.Build.VERSION.SDK_INT >= apiLevel;
    }
}