0

When i convert bitmap to string with toString() i get something like that: android.graphics.Bitmap@40da7c08. I want that name to be always the same so i can compare it. Is there any way to do it?

Blake Gibbs
  • 485
  • 1
  • 9
  • 25

2 Answers2

1

It would be better to extend the bitmap class and add another method to generate a unique identifier that you understand.

draksia
  • 2,371
  • 2
  • 20
  • 25
  • I have a list of bitmaps that a draw on canvas, those are four different bitmaps and i want to know which one has been clicked – Blake Gibbs Sep 18 '12 at 18:52
0

This is the default implementation of the toString() method in Java. Its basically the fully classified name of the class, followed by the hexcode of the object.

I would suggest that you do your comparison based on the equals() method or wrap your Bitmap objects inside a class of yours and add a name or id property.

midhunhk
  • 5,560
  • 7
  • 52
  • 83
  • so there is no way to change it boucase i want to compare that bitmap to another – Blake Gibbs Sep 18 '12 at 18:24
  • do comparison using the .equals() method which checks if both the references are pointing to the same object, not necessarily that both object contains the same data. – midhunhk Sep 18 '12 at 18:26
  • @Itsmeyxc No you can't change it. You could override the `Bitmap` class yourself, however, and override the implementation of `toString()` to do a comparison on the pixels, something like [this example](http://stackoverflow.com/a/7696320/321697) shows. – Kevin Coppock Sep 18 '12 at 18:26