Look at AsyncTask.

The key thing is that you should never do anything that blocks or
takes a long time on the main (UI) thread. That especially includes
anything related to the network -- IO, opening/closing connections, or
even resolving hostnames.

A service by itself does not solve that, as it also runs on the main
thread.

The key idea is that you start an AsyncTask, and it runs the slow part
on another thread, and then arranges to run something when that
finishes.

So your button will start the AsyncTask, which will call its
onPostExecute() method to do whatever your really want the button to
do when the JSON data comes back.


On Aug 11, 12:19 pm, Daniel Favela <dfav...@gmail.com> wrote:
> Greetings.
>
> I'm trying to make an app where a button will invoke a web service's API
> call (it'll be my own web service; the call/functionality is not relevant).
> I know how to make a new listener that invokes an activity, but that is
> insufficient here since I'll still need to make a call out to a web service
> through it.
>
> What is it I'm doing here?  Is this a service that I'm looking at?  A
> content provider that I'll be invoking that somehow gets data from a web
> service?
>
> If the protocol is important, let's assume I'm using JSON.
>
> Thank you for any help!
>
> -Danny

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