I am new to Android programming. I am developing and Android App that would capture an image after which it would send the image to a server where it would be modified and then returned back to the phone. My question is can i use a Java Servlet running on the server to handle this request and also how can I do this, like how do is send the image back to the phone.
Asked
Active
Viewed 212 times
0
-
I am not sure on also how do is send photo from the phone to Sever and back ...my choice would be to use a server with java servelt – SaNmm Oct 26 '11 at 01:16
-
Welcome to Stackoverflow! If you a response is helpful, pleas up vote it. If the response successfully answers you question please click the green check mark next to it to accept the answer. Also please look at http://stackoverflow.com/questions/how-to-ask for advice on how to write a good question – Kurtis Nusbaum Oct 26 '11 at 01:42
2 Answers
1
Yes, this is possible. You've asked a very general question so all I can do is give you a general answer. You're going to want to do your communication with the server on a separate thread, not the UI thread. I suggest using an AsyncTaskLoader for this. To actually communicate with the server, use the HttpUrlConnection. When you get a response from the server, have the onLoaderFinished callback present the image to your user in your activity.
For more on Loaders, checkout this documentation.

Kurtis Nusbaum
- 30,445
- 13
- 78
- 102
0
for client-server transactions, it's better to use a service rather than asynctask.

josephus
- 8,284
- 1
- 37
- 57
-
can you give any example for such service i am planning to use JSON and HTTP Client and HTTPPOst to pass it to the server. – SaNmm Oct 26 '11 at 05:47
-
can't whip up a working example for you right now, but this [link](http://stackoverflow.com/questions/3197335/android-restful-api-service) can help you start with creating your own service, while this [link](http://timewasted.net/?p=127) should teach you how to do a rest request and handle response using HTTP Client. – josephus Oct 26 '11 at 12:16
-
Not always, it depends. If it's just going to be a one shot deal and none of the data is going to be cached, you probably don't have to spend time on the complexities of a Service. – Kurtis Nusbaum Oct 31 '11 at 14:11