ravi
ravi

Reputation: 2792

How to call web service in background?

I am posting images using JSON. Whenever I take a picture i have to call the webservice. This webservice call may take some time. I dont want to use Thread nor Asynchronous Task for this. I want to call the Webservice in background and able to perform operations in foreground(button click, entering some data in edittext etc).

I guess this can be achieved by using Service. Please provide me some tutorials for this.

Is there any way?

Thanks in advance.

Upvotes: 0

Views: 1799

Answers (2)

Rohan Kandwal
Rohan Kandwal

Reputation: 9336

Services are basically used when we want to run some code in background even when a application or the present activity gets closed. Use Services only if you need it and be sure to destroy it when you are done otherwise you will waste memory and that is not good.

Here are some great tutorials of implementing service. Firstly make some sample codes to learn how to handle services and see their lifecycle, etc. and then try to implement them in you code otherwise you may be confused xamarin.com vogella.com and technotopia.com. Happy Coding!!!

Upvotes: 3

If you need to handle upload within a serial queue service, take a look at IntentService.
and implement the abstracted onHandleIntent() method.

Upvotes: 0

Related Questions