android - How to get Image's string value(or an Image reference) from a ImageView -
i have assigned textview , imageview below,
text = (textview) findviewbyid(r.id.textview01); image = (imageview) findviewbyid(r.id.imageview01); now values change dynamically in program (image changed online url), , @ end need store values in db future use. here text value as
string textvalue = text.gettext().tostring(); but how store value imageview?
string imagevalue = image.somefunctionthatreturnsimagereferenceinstring(); is there such functions??
 or how this.. pls help
you need convert image-view base64 string below.
1]convert imageview bitmap.
  imageview.builddrawingcache();   bitmap bmap = imageview.getdrawingcache(); 2]bitmap base64 string.
public string getencoded64imagestringfrombitmap(bitmap bitmap) {       bytearrayoutputstream stream = new bytearrayoutputstream();       bitmap.compress(compressformat.jpeg, 70, stream);       byte[] byteformat = stream.tobytearray();       // base 64 string       string imgstring = base64.encodetostring(byteformat, base64.no_wrap);   return imgstring; } 3]base64 bitmap.
byte[] decodedstring = base64.decode(base64string.getbytes(), base64.default); bitmap decodedbyte = bitmapfactory.decodebytearray(decodedstring, 0, decodedstring.length); set bitmap imageview.
Comments
Post a Comment