Example usage for android.graphics.drawable Icon createWithAdaptiveBitmap

List of usage examples for android.graphics.drawable Icon createWithAdaptiveBitmap

Introduction

In this page you can find the example usage for android.graphics.drawable Icon createWithAdaptiveBitmap.

Prototype

public static Icon createWithAdaptiveBitmap(Bitmap bits) 

Source Link

Document

Create an Icon pointing to a bitmap in memory that follows the icon design guideline defined by AdaptiveIconDrawable .

Usage

From source file:com.android.contacts.DynamicShortcuts.java

private void addIconForContact(long id, String lookupKey, String displayName, ShortcutInfo.Builder builder) {
    Bitmap bitmap = getContactPhoto(id);
    if (bitmap == null) {
        bitmap = getFallbackAvatar(displayName, lookupKey);
    }/*from   w  ww .j  a  v  a2s. c  om*/
    final Icon icon;
    if (BuildCompat.isAtLeastO()) {
        icon = Icon.createWithAdaptiveBitmap(bitmap);
    } else {
        icon = Icon.createWithBitmap(bitmap);
    }

    builder.setIcon(icon);
}