Java tutorial
//package com.java2s; // Use of this source code is governed by a BSD-style license that can be import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import android.graphics.drawable.Drawable; import android.os.Build; public class Main { /** * @see android.content.res.Resources#getDrawable(int id). */ @SuppressWarnings("deprecation") public static Drawable getDrawable(Resources res, int id) throws NotFoundException { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return res.getDrawable(id, null); } else { return res.getDrawable(id); } } }