It takes some time to generate colors from supplied resource, that is why you should use Pallet asynchronously.
Bitmap bm = BitmapFactory.decodeResource(getResources(), VersionData.getOsDrawable(osVersion));
Palette.PaletteAsyncListener listener = new Palette.PaletteAsyncListener() {
public void onGenerated(Palette palette) {
Log.d("Palette", "Palette has been generated");
TextView tv1 = (TextView) findViewById(R.id.tv1);
TextView tv2 = (TextView) findViewById(R.id.tv2);
// use initialized Pallet here tv1.setBackgroundColor(palette.getVibrantColor(0x000000));
tv2.setBackgroundColor(palette.getVibrantColor(0x000000));
//Noticed the Expanded white doesn't show everywhere, use Palette to fix this
collapsingToolbar.setExpandedTitleColor(palette.getVibrantColor(0x000000));
}
};
// Start this Async, because it takes some time to generate
Palette.from(bm).generate(listener);
There is a excellent Material Design sample project
https://github.com/mwolfson/android-historian