I’m trying to make a Android Honeycomb tablet app for a social website. I created a class to hold various API functions, like this one:
public String getBlogInfo(String blogName)
which contains HttpGet and other networked things. I’m calling that function from the main thread like so:
APIHelper apiHelp = new APIHelper();
String blogInfo = apiHelp.getBlogInfo(blog);
Of course, after receiving the error NetworkOnMainThreadException and doing a little research I found that I need to use Handlers or AsyncTasks to pull this off properly. I just really don’t know how I would start. I would love a nudge in the right direction, and if you need more of my code I’ll be happy to provide it.
I found a good solution here:
http://ajeyasharma.com/2010/04/returning-values-from-asynctask.html
Works like a charm