I have an image in the image table field and I want to use this image in my application my php page
$user = array(); $user["image"] = base64_encode($result["image"]); // success $response["success"] = 1; // user node $response["image_table"] = array(); array_push($response["image_table"], $user);
when i use this array in my application i use this ...
if (success == 1) { address = json.getJSONArray(TAG_IMAGE_TABLE); for (int i = 0; i < address.length(); i++) { JSONObject c = address.getJSONObject(i); image = c.getString(TAG_IMAGE); }
he gives me the result as
json response: {"success":1,"image_table": [{"image":"iVBORw0KGgoAAA...................."
when i use this image in my image view i use this as
ImageView ivProperty = ((ImageView) myContentView.findViewById(R.id.image_property)); byte[] decodedString; try { decodedString = Base64.decode(image, Base64.URL_SAFE); Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); ivProperty.setImageBitmap(decodedByte); } catch (IOException e) {
But this gives me a null pointer exception
My logcat values
03-27 10:10:44.355: E/AndroidRuntime(2391): java.lang.NullPointerException: Input string was null. 03-27 10:10:44.355: E/AndroidRuntime(2391): at com.big_property_info.Base64.decode(Base64.java:1242) 03-27 10:10:44.355: E/AndroidRuntime(2391): at com.big_property_info.MainActivityMap$GeocoderTask$2.getInfoContents(MainActivityMap.java:314)
How to solve this null pointer exception ... when I get the image string .....
android php mysql android-bitmap android-imageview
Tufan
source share