### Question:
IconCompat { public static IconCompat createWithData(byte[] data, int offset, int length) { if (data == null) { throw new IllegalArgumentException("Data must not be null."); } final IconCompat rep = new IconCompat(TYPE_DATA); rep.mObj1 = data; rep.mInt1 = offset; rep.mInt2 = length; return rep; } private  IconCompat(int mType); static IconCompat createWithResource(Context context, @DrawableRes int resId); static IconCompat createWithBitmap(Bitmap bits); static IconCompat createWithAdaptiveBitmap(Bitmap bits); static IconCompat createWithData(byte[] data, int offset, int length); static IconCompat createWithContentUri(String uri); static IconCompat createWithContentUri(Uri uri); @IconType int getType(); @NonNull String getResPackage(); @IdRes int getResId(); @NonNull Uri getUri(); IconCompat setTint(@ColorInt int tint); IconCompat setTintList(ColorStateList tintList); IconCompat setTintMode(PorterDuff.Mode mode); @RequiresApi(23) Icon toIcon(); Drawable loadDrawable(Context context); @RestrictTo(LIBRARY_GROUP) @SuppressWarnings("deprecation") void addToShortcutIntent(@NonNull Intent outIntent, @Nullable Drawable badge,
            @NonNull Context c); Bundle toBundle(); @Override String toString(); static @Nullable IconCompat createFromBundle(@NonNull Bundle bundle); @RequiresApi(23) @Nullable static IconCompat createFromIcon(@NonNull Icon icon); @IconType @RequiresApi(23) static int getType(@NonNull Icon icon); @Nullable @RequiresApi(23) static String getResPackage(@NonNull Icon icon); @IdRes @RequiresApi(23) static int getResId(@NonNull Icon icon); @Nullable @RequiresApi(23) Uri getUri(@NonNull Icon icon); static final int TYPE_UNKOWN; }### Answer:
@Test @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) public void testCreateWithData() { Bitmap bitmap = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888); bitmap.eraseColor(Color.YELLOW); ByteArrayOutputStream out = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); byte[] bytes = out.toByteArray(); byte[] resultCopy = Arrays.copyOf(bytes, bytes.length + 100); for (int i = bytes.length - 1; i >= 0; i--) { resultCopy[i + 20] = resultCopy[i]; } IconCompat compat = IconCompat.createWithData(resultCopy, 20, bytes.length); Drawable d = compat.toIcon().loadDrawable(InstrumentationRegistry.getContext()); assertTrue(d instanceof BitmapDrawable); assertTrue(bitmap.sameAs(((BitmapDrawable) d).getBitmap())); }
@Test public void testDataIconCompat() { byte[] data = new byte[4]; data[0] = data[1] = data[2] = data[3] = (byte) 255; verifyIconCompatValidity(IconCompat.createWithData(data, 0, 4)); }