Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay image in ImageView from a binary array
    primarykey
    data
    text
    <p>I have a web service to retrieve images which are converted to string and in my android app convert back to binary array. but unfortunately in stops with a force close error.<br> I'm using the code explained here to fill the imageView:<br> <a href="https://stackoverflow.com/questions/3520019/display-image-from-bytearray">display image from byteArray</a> </p> <p>This is my web service method in C# which sends me the data: </p> <pre><code>public String GetPersonImage() { int PersonCode = 1; JPerson person = new JPerson(PersonCode); Image personImage = person.PersonImage; if (personImage == null) return "Nothing"; using (MemoryStream ms = new MemoryStream()) { personImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); return Convert.ToBase64String(ms.ToArray()); } } </code></pre> <p>And this is how I'm trying to put my data in an ImageView:</p> <pre><code> String pic = t.execute().get(); byte[] picData = pic.getBytes(); ImageView imgPerson = (ImageView) findViewById(R.id.imgPerson); Bitmap bitmap = BitmapFactory.decodeByteArray(picData, 0, picData.length); imgPerson.setImageBitmap(bitmap); </code></pre> <p>the pic variable contains the data from web service. And this is my log cat:</p> <pre><code>11-13 14:08:23.092: D/dalvikvm(29229): GC_FOR_ALLOC freed 2290K, 41% free 8004K/13420K, paused 27ms, total 27ms 11-13 14:08:23.092: I/dalvikvm-heap(29229): Forcing collection of SoftReferences for 185326656-byte allocation 11-13 14:08:23.143: D/dalvikvm(29229): GC_BEFORE_OOM freed 9K, 41% free 7994K/13420K, paused 42ms, total 43ms 11-13 14:08:23.143: E/dalvikvm-heap(29229): Out of memory on a 185326656-byte allocation. 11-13 14:08:23.143: I/dalvikvm(29229): "main" prio=5 tid=1 RUNNABLE 11-13 14:08:23.143: I/dalvikvm(29229): | group="main" sCount=0 dsCount=0 obj=0x40a729a0 self=0x2a00bba8 11-13 14:08:23.143: I/dalvikvm(29229): | sysTid=29229 nice=0 sched=0/0 cgrp=apps handle=1073849308 11-13 14:08:23.143: I/dalvikvm(29229): | state=R schedstat=( 1210556247 2173314492 1073 ) utm=93 stm=28 core=0 11-13 14:08:23.143: I/dalvikvm(29229): at android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method) 11-13 14:08:23.151: I/dalvikvm(29229): at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:428) 11-13 14:08:23.151: I/dalvikvm(29229): at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:446) 11-13 14:08:23.151: I/dalvikvm(29229): at com.example.shareholders.PersonnelInfo.clickHandler(PersonnelInfo.java:116) 11-13 14:08:23.151: I/dalvikvm(29229): at java.lang.reflect.Method.invokeNative(Native Method) 11-13 14:08:23.151: I/dalvikvm(29229): at java.lang.reflect.Method.invoke(Method.java:511) 11-13 14:08:23.151: I/dalvikvm(29229): at android.view.View$1.onClick(View.java:3594) 11-13 14:08:23.151: I/dalvikvm(29229): at android.view.View.performClick(View.java:4204) 11-13 14:08:23.151: I/dalvikvm(29229): at android.view.View$PerformClick.run(View.java:17355) 11-13 14:08:23.151: I/dalvikvm(29229): at android.os.Handler.handleCallback(Handler.java:725) 11-13 14:08:23.151: I/dalvikvm(29229): at android.os.Handler.dispatchMessage(Handler.java:92) 11-13 14:08:23.151: I/dalvikvm(29229): at android.os.Looper.loop(Looper.java:137) 11-13 14:08:23.151: I/dalvikvm(29229): at android.app.ActivityThread.main(ActivityThread.java:5041) 11-13 14:08:23.151: I/dalvikvm(29229): at java.lang.reflect.Method.invokeNative(Native Method) 11-13 14:08:23.151: I/dalvikvm(29229): at java.lang.reflect.Method.invoke(Method.java:511) 11-13 14:08:23.151: I/dalvikvm(29229): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 11-13 14:08:23.151: I/dalvikvm(29229): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 11-13 14:08:23.151: I/dalvikvm(29229): at dalvik.system.NativeStart.main(Native Method) 11-13 14:08:23.161: D/skia(29229): --- decoder-&gt;decode returned false 11-13 14:08:23.161: D/AndroidRuntime(29229): Shutting down VM 11-13 14:08:23.161: W/dalvikvm(29229): threadid=1: thread exiting with uncaught exception (group=0x40a71930) 11-13 14:08:23.182: E/AndroidRuntime(29229): FATAL EXCEPTION: main 11-13 14:08:23.182: E/AndroidRuntime(29229): java.lang.IllegalStateException: Could not execute method of the activity 11-13 14:08:23.182: E/AndroidRuntime(29229): at android.view.View$1.onClick(View.java:3599) 11-13 14:08:23.182: E/AndroidRuntime(29229): at android.view.View.performClick(View.java:4204) 11-13 14:08:23.182: E/AndroidRuntime(29229): at android.view.View$PerformClick.run(View.java:17355) 11-13 14:08:23.182: E/AndroidRuntime(29229): at android.os.Handler.handleCallback(Handler.java:725) 11-13 14:08:23.182: E/AndroidRuntime(29229): at android.os.Handler.dispatchMessage(Handler.java:92) 11-13 14:08:23.182: E/AndroidRuntime(29229): at android.os.Looper.loop(Looper.java:137) 11-13 14:08:23.182: E/AndroidRuntime(29229): at android.app.ActivityThread.main(ActivityThread.java:5041) 11-13 14:08:23.182: E/AndroidRuntime(29229): at java.lang.reflect.Method.invokeNative(Native Method) 11-13 14:08:23.182: E/AndroidRuntime(29229): at java.lang.reflect.Method.invoke(Method.java:511) 11-13 14:08:23.182: E/AndroidRuntime(29229): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 11-13 14:08:23.182: E/AndroidRuntime(29229): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 11-13 14:08:23.182: E/AndroidRuntime(29229): at dalvik.system.NativeStart.main(Native Method) 11-13 14:08:23.182: E/AndroidRuntime(29229): Caused by: java.lang.reflect.InvocationTargetException 11-13 14:08:23.182: E/AndroidRuntime(29229): at java.lang.reflect.Method.invokeNative(Native Method) 11-13 14:08:23.182: E/AndroidRuntime(29229): at java.lang.reflect.Method.invoke(Method.java:511) 11-13 14:08:23.182: E/AndroidRuntime(29229): at android.view.View$1.onClick(View.java:3594) 11-13 14:08:23.182: E/AndroidRuntime(29229): ... 11 more 11-13 14:08:23.182: E/AndroidRuntime(29229): Caused by: java.lang.OutOfMemoryError 11-13 14:08:23.182: E/AndroidRuntime(29229): at android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method) 11-13 14:08:23.182: E/AndroidRuntime(29229): at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:428) 11-13 14:08:23.182: E/AndroidRuntime(29229): at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:446) 11-13 14:08:23.182: E/AndroidRuntime(29229): at com.example.shareholders.PersonnelInfo.clickHandler(PersonnelInfo.java:116) 11-13 14:08:23.182: E/AndroidRuntime(29229): ... 14 more 11-13 14:13:23.284: I/Process(29229): Sending signal. PID: 29229 SIG: 9 11-13 14:13:23.751: E/Trace(31566): error opening trace file: No such file or directory (2) 11-13 14:13:23.791: I/METHOD INFO(31566): AppMenu.onCreate():21 11-13 14:13:23.912: D/dalvikvm(31566): GC_CONCURRENT freed 61K, 8% free 2752K/2964K, paused 15ms+11ms, total 77ms 11-13 14:13:24.051: D/gralloc_goldfish(31566): Emulator without GPU emulation detected. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload