I have created an application which first capture an image then apply color of vibrant palette to text.
Here is my code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button)findViewById(R.id.btn);
iv = (ImageView)findViewById(R.id.iv);
tv = (TextView)findViewById(R.id.tv);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent c = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(c,0);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap imageBitmap = (Bitmap) data.getExtras().get("data");
iv.setImageBitmap(imageBitmap);
iv.setScaleType(ImageView.ScaleType.FIT_XY);
if (imageBitmap != null && !imageBitmap.isRecycled()) {
Palette palette = Palette.from(imageBitmap).generate();
Palette.PaletteAsyncListener paletteAsyncListener = new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
int defaultColor = 0x000000;
int vibrant = palette.getVibrantColor(defaultColor);
tv.setTextColor(vibrant);
}
};
}
}
However, this code doesn't change color of my textview
.
When I try to print that integer it returns long number, do you know what is wrong?