Example usage for android.content.pm PackageManager getUserBadgedIcon

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

Introduction

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

Prototype

public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);

Source Link

Document

If the target user is a managed profile, then this returns a badged copy of the given icon to be able to distinguish it from the original icon.

Usage

From source file:Main.java

/**
 * @see android.content.pm.PackageManager#getUserBadgedIcon(Drawable, android.os.UserHandle).
 *//*from w ww  .  j  a v  a 2s .co  m*/
public static Drawable getUserBadgedIcon(Context context, int id) {
    Drawable drawable = getDrawable(context.getResources(), id);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        PackageManager packageManager = context.getPackageManager();
        drawable = packageManager.getUserBadgedIcon(drawable, Process.myUserHandle());
    }
    return drawable;
}