I'm trying to send an image from an sql database to an android client. I'm doing this by way of a php middleman. The code stops working due to a null returning of the method below. My php code(works fine to encode image into base64(decoded the encoding and it worked)):
<?php //get image function ob_base64_encode($c) { $a=base64_encode($c); $arr = array('base64' => $a); return json_encode($arr); } $image=resize(48,80,$image); // And pass its name as a string ob_start('ob_base64_encode'); imagepng($image); ob_end_flush(); ?> My android code: public static Bitmap getIm(String IP, int height, int width) { ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); //Network queries and gets response(works) String result = Network.getResponse(IP, nameValuePairs); //manually decode string since for some reason JSON decode won't work(also works) String r=result.split(":\"")[1]; r=r.split("\"")[0]; //decode string byte[] decodedString = Base64.decode(r, Base64.DEFAULT); Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); return decodedByte; //returns null } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en