Example usage for android.content.pm PackageManager getUserBadgedDrawableForDensity

List of usage examples for android.content.pm PackageManager getUserBadgedDrawableForDensity

Introduction

In this page you can find the example usage for android.content.pm PackageManager getUserBadgedDrawableForDensity.

Prototype

public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable, UserHandle user, Rect badgeLocation,
        int badgeDensity);

Source Link

Document

If the target user is a managed profile of the calling user or the caller is itself a managed profile, then this returns a badged copy of the given drawable allowing the user to distinguish it from the original drawable.

Usage

From source file:Main.java

/**
 * @see android.content.pm.PackageManager#getUserBadgedDrawableForDensity(Drawable drawable,
 * UserHandle user, Rect badgeLocation, int badgeDensity).
 *///from w  ww .  j  ava  2s  . c om
public static Drawable getUserBadgedDrawableForDensity(Context context, Drawable drawable, Rect badgeLocation,
        int density) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        PackageManager packageManager = context.getPackageManager();
        return packageManager.getUserBadgedDrawableForDensity(drawable, Process.myUserHandle(), badgeLocation,
                density);
    }
    return drawable;
}