开发者

Android Honeycomb network operations

I've got this problem that I just can't seem to find a way around.

I'm working on an Android app for Honeycomb tablets, and it needs to connect to the internet, download some data and then update the UI once it's done. The thing is, however, that I need to do this any given number of times in succession. My problem right now is that I'm using a Runnable on a new thread with a Handler that updates the UI when the network calls have been made.

My big issue is that I cannot be sure that the data has actually been downloaded to the device yet. All I know is that the network calls are made, and that's it. I cannot be sure if anything's been downloaded.

The big problem in my case lies in the fact that you cannot use the main thread for your network operations in Honeycomb. If I had been using the main thread,

I'd really love some help on this subject. Thanks.

UPDATE: I'll try to explain everything a bit better:

I've created a class that makes the network calls in a separate thread, and this class also contains a few methods that return various data from those network calls. However, the network calls can vary in length - depending on the user's network speed - so if I call one of the methods, i.e. getTitle(), I can't be sure that the network call has finished yet.

I need to do something along the lines开发者_运维问答 of this: '- Create new instance of the class (this beings a download in a new thread) - Make sure that the download has completed, so I can use the data from it - Update a progressbar'

That's basically what I need to do. Hope it helped. Thanks


All I know is that the network calls are made, and that's it. I cannot be sure if anything's been downloaded.

This doesn't really make sense to me. So you're making the network calls, are you getting a response? Are you storing the data?

You're not really supposed to use the main thread for network connections, do you want the user to be completely paralyzed while these network calls are happening?

If you use an AsyncTask for example, the onPostExecute(Object object) gets called when your calls are done and you can daisy chain those network calls using that...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜