Thursday, January 13, 2011

Consuming REST Web Service using Android

In this tutorial, we will find out how to create an Android application to consume REST Web Service.

We will create android application which will consume web service in this post .
Our application should look like this.

Create a new Android Application named "Note Android".
Modify AndroidManifest and add INTERNET permission.

Next, create the view for posting new note : main.xml



And the view for viewing all of our notes. There is no component here. Only a layout because we will create the component programmatically



Next, create our view for posting note : DatabaseAndroid.java



And the code for parsing xml retrieved from web service and present each element on a TextView : ViewDatabase.java



Run our application and try creating new notes.

Have fun!

5 comments:

  1. Hello
    When i have tried above code and customize according to my web service and when i click on post button it shows return in response "bad request 400". can you please help me.

    ReplyDelete
  2. hi tom,
    can u pls help me out..i am getting connection refused in log file wen i try to post a note..how can get over this???

    ReplyDelete
  3. can u provide the .zip source code???????????????

    ReplyDelete
    Replies
    1. u cant code!!!!!

      why u need the .zip source code????

      don't be lazy.

      Delete
    2. Is there any problem with u??
      Then why u r behaving so rude??
      If .zip code has been provided u will be the 1st to download it....

      Delete