I'm writing an app for android in Java, and a server also in Java. I'm looking for a way to communicate with the server like a web service. I want to be able to call functions written in the server from the client.
Asked
Active
Viewed 1,531 times
2
-
1That's exactly what RPC was designed for. – kirilloid May 04 '14 at 06:20
1 Answers
2
There are many ways but the best way is to use volley https://github.com/mcxiaoke/android-volley
http://arnab.ch/blog/2013/08/asynchronous-http-requests-in-android-using-volley/
Or simply you can use a AsynTask for network calls How to use AsyncTask correctly in Android
-
OK I'll read about volley. By the way I tried using asynctask, but using it allows me to send just strings through the sockets. – itaied May 04 '14 at 08:23
-
I added volley to my project, but there one thing I still dont get, how do I call server functions from the client? Lets say I have a server written in Java, and it has few functions, how can I call a specific function and send it parameters? The only thing I found was sending JSON to a url, but how should the server interpret the request? – itaied May 06 '14 at 11:20
-
You have to use a framework to interpret that like you can use a jersey library – Ravin Jul 10 '14 at 19:57
-
You should make a web service which can be of post , get , put, delete method. For making such restful web services you should read http://www.vogella.com/tutorials/REST/article.html http://android.programmerguru.com/android-restful-webservice-tutorial-how-to-create-restful-webservice-in-java-part-2/ https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&ved=0CDEQFjAC&url=http%3A%2F%2Favilyne.com%2F%3Fp%3D105&ei=fvG-U7_FBonJuASFiYCIBA&usg=AFQjCNFZedzlwQ6TUgxm-jYV07nG74ZZnw&sig2=ppGCz33ZHXRiAh6P2xCxcg&bvm=bv.70810081,d.c2E – Ravin Jul 10 '14 at 20:06