I am developing an Android based app that does both the things:
- Add data to the server.
- Fetch data from the server.
Data consists of a multimedia file which can be either:
- Picture + Some info about Picture
- Video + Some info about Video
- Simple Text + Some info about the text
In the above, info consists of things like Latitude, longitude, user name etc.
I want to know as to how to achieve the desired ?
I have been suggested to use JSON based object and pass it to the android app. I know how to parse the JSON object but have no idea about things like:
- How does the android app running on mobile device requests for JSON object ? (meaning which URL to ask)
- How to pass the multimedia object (Picture/Video) from server to App in form of JSON object?
- How to send data from android app running of android based phone to the server ?
Thanks in advance !
Let me try to answer your questions;
You need to have a service running on the server. Android parses the json and sends it to this service. So you will need to use the URL of your service.
You can pass multimedia objects to the service by converting it to a Byte or Base64String.'
With regards to how to parse the json and send it to the server, I'd recommend you look at google-gson. This is one of the most commonly used libraries when working with JSON
Look into this link for a more indepth tutorial on Json parsing Note: While JSON is the recommended way to pass objects to and from the server, wsdl is another option you can use.