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.graphics.drawable.Drawable; import android.os.Build; public class Main { /** * @see android.content.res.Resources#getDrawableForDensity(int id, int density). */ @SuppressWarnings("deprecation") public static Drawable getDrawableForDensity(Resources res, int id, int density) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return res.getDrawableForDensity(id, density, null); } else { return res.getDrawableForDensity(id, density); } } }