You're doing it wrong, thread.sleep is unnecessary.
I'm thinking something changed in the 2.2-2.3.x Dalvik implementation, but
try using the following to stream a file:

BufferedInputStream inBuf = new BufferedInputStream(socket.getInputStream,
80);



byte buf[] = new byte[1024 * 2];

int len;

int total = 0;

while ((len = inBuf.read(buf)) > 0) {

    total += len;

}



inBuf.close();


On Mon, May 2, 2011 at 9:41 PM, Anila Khwaja <anilakhw...@gmail.com> wrote:

> I've written a piece of code which connects through socket and receive
> data to load bitmap image on phone ... it works perfectly in android
> 2.3.X but blocks the data on android 2.2 when bytes read reached
> 2048.. it doesn't read anything more than that and get stucked over
> there
>
> I read on multiple forums that android 2.2 block large files but if
> the data on stream can split into chunks then it can be read.
>
> here is the piece of code i've written for it
>
>                                        isRvcdData =
> socket.getInputStream();
>                                        byte[] chunk = new byte[1024];
>
>                                        if (socket.isConnected() &&
> !socket.isClosed())
>                                        {
>                                                while
> (isRvcdData.available() < chunkLength)
>                                                {
>                                                        Thread.sleep(10);
>                                                }
>                                                iByteLengthRead =
> isRvcdData.read(chunk, 0, 1024);
>                                        }
>
> please help me out as how to read the whole data from stream on
> android 2.2
>
> --
> 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




-- 
~ Jeremiah:9:23-24
Android 2D MMORPG: http://solrpg.com/,
http://www.youtube.com/user/revoltingx

-- 
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

Reply via email to