0

What are the best ways to connect site and show it's data on an android application ? Also does I have to create anything on server where the site is for using JSON ? I am new to programming web android application's, though I searched a lot I didn't find anything which would explain me straight to the point.

stevyhacker
  • 1,646
  • 1
  • 19
  • 29

2 Answers2

1

You're on the solid ground starting out using JSON as the interchange between the two.

Alot of popular mobile apps like Twitter and Foursquare have restful APIs set up to interact with their mobile clients by exchanging HTTP requests that contain data formatted as JSON. Most of the communication between the two can be accomplished with HTTP requests using the standard GET and POST methods.

A good place to start would be setting up some server endpoints that output this data and then setting up your android app to request and parse this data just like a browser would. You just need to set the appropriate mimetypes on your server end (application/json).

Most modern server-side languages have implemented modules/functions that can take their native data structures and approximate them in serialized JSON (PHP's json_encode(), python's json.dumps() etc) These can be used to output data from within the app or database to your mobile client where it can be interpreted and used in the Java environment there.

DeaconDesperado
  • 8,971
  • 6
  • 43
  • 75
1

To pass back JSON you need to set the mime type (http://stackoverflow.com/questions/477816/the-right-json-content-type), which is application/json.

If you are passing back JSON or XML then the client just needs to make the appropriate http call, most likely GET, perhaps POST, to actually retrieve the information.

You can use something like this as a starting point:

http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/

James Black
  • 40,548
  • 9
  • 79
  • 153