Android Restful Web Service Client Example

In this tutorial you learn how to create an android restful web service client to consume a restful web service developed in Java.

Before making the android client make sure the web service is already running on server. I am using apache tomcat server to run the java web service in my local system.

If you don’t know how to make Java restful web service then read below tutorial.

Also Read: Create Simple Java RESTful Web Services Using Jersey

In this example the android client will send some string to server which is reversed and sent back to the android client.

 

Android Restful Web Service Client Example

1. Create a new android project with package name com.androidrestfullwebservice

2. I am using Volley library to load data from server. If you don’t know how to use this library then read below tutorial.

Also Read: Android Volley Tutorial With Example

3. Just copy and paste below line in build.gradle (Module) file to add dependency for Volley library. After adding Sync the project.

 

4. As we are doing network related work so add internet access permission in AndroidMainifest.xml file by adding following line.

 

5. Create an activity and add following code in respective files.

activity_main.xml

 

MainActivity.java

 

Note: Make sure to replace 192.168.1.3 with your system IPv4. You can find it by running ipconfig command in command prompt.

 

6. Now run the project.

 

Screenshot

Android Restful Web Service Client Example

Comment below if you are facing any difficulty to make android restful web service client.

Leave a Reply

Your email address will not be published. Required fields are marked *