Image Doesn't Show in my Android ImageView

2019-07-20 18:03发布

问题:

I am creating android web application using RESTFul web services.i have declared code to save Image like this

onCreateMethod()

    ImageView iv = (ImageView) findViewById(R.id.hotelLogoImageView);
    iv.setDrawingCacheEnabled(true);

onSave()

    Bitmap b = ((BitmapDrawable) iv.getDrawable()).getBitmap();
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    b.compress(Bitmap.CompressFormat.PNG, 100, bos);
    logo = bos.toByteArray();

then i am using RESTFul webservices.so i converted logo(byte Array) to String and passed logo into NameValuePair like:

private ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("hotel_logo",String.valueOf(logo)));

In my server side code, again i converted my String value to byteArray like:

byte[] imgLogo = hotelParams.getFirst("hotel_logo").getBytes(
            Charset.forName("UTF-8"));

Finally i saved imgLogo value in my phpMyAdmin Database.it's also Stored in Database like [BLOB - 10 B]

Now I have to set that image into ImageView.so I have used this method.like

    JSONObject jsonObject = new JSONObject(response);
    byte[] logo = Base64.decode(jsonObject.getString("hotel_logo"),
            Base64.DEFAULT);
    Bitmap hotel_Logo = BitmapFactory.decodeByteArray(logo, 0, logo.length);
    hotelLogo.setImageBitmap(hotel_Logo);

After finish this code.there is no error.But Image Doesn't Show in ImageView.please Help me what i have done mistake?