A while ago I worked on a parser for some binary data that parsed the data as the data was coming down the network. The important thing being that we didn’t have to wait for the entire set of bytes to download before we started parsing. This GREATLY improved the speed because it allowed for more threading, we were able to do something while the system waited for bytes.
On Android, is this possible with the Android HTTP classes? I would like something roughly similar too when some number of bytes are available, a callback is called, allowing me to parse those bytes while the system continues loading more bytes. I’ve worked with DefaultHttpClient a bit but am not sure if it supports what I’m looking for.
Sure. The standard pattern for downloading data usually looks something like this:
HttpResponsehas a method calledgetContentwhich returns anInputStream. You can just read a few bytes, do or queue off some processing on that data, then get some more data. Repeat as necessary.