I had the question:
Why is this not working sometimes?
I was comparing bitmaps and executing code accordingly, but the code wasn't executing. My question received many great answers. One of the answers, which worked, suggested to remove ==
, and change it to .sameAs()
in order to make my app work on newer phones.
ClickGround = v.getBackground(); //Get the background of button clicked (ClickGround is a bitmap)
BitClick = ((BitmapDrawable) ClickGround).getBitmap(); //the bitmap background of the button clicked
So, why does using the sameAs()
method work more efficiently than using ==
to compare bitmaps? Also, why does using ==
work in lower versions of android (kitkat), and sameAs
in higher versions?
Thanks,
Ruchir