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.
You can do that by converting to Base64String. Check this link
Related
I want a sample WebService URL, which can be used to practice android networking with volley.
I know there are many sample URLs which send Json data but I want a WebService URL which accepts and store data (may be in MySql Database) like(email,password) sent by android app.
I want to practice these things but I have not found required setup for this,
if such type of free WebService is not available then please suggest me how can I practice android networking, specially Posting data to server (usually used in user signup and sign-in)
Thanks :)
Here is what you want to practice Networking
Webservice Type : REST
Returns a list of cities and placenames in the bounding box, ordered by relevancy (capital/population). Placenames close together are filterered out and only the larger name is included in the resulting list.
JSON URL :
Click here
Same output in XML format :-
XML URL : Click here
I need to retrieve huge amounts of data from a database through a web service from an Android app. I have two different ways to do this, and I wanted some advice on it:
1. The first option is to create a .php file on the server side that managed any POST coming from the client (Android app). The server would then create a JSON response. Finally we would parse this response using a JSON parser in Android. This is also known as the REST scheme.
2. The second option is to create a SERVLET, execute it from the client (Android), have the servlet send the request to the database for us, and finally parse that data from Android. Obviously the servlet would be written so that it could easily interact with the database.
Points to note (so as to decide which option is better):
1. I won't be storing anything in the database from the client. That is, my Android app is read-only.
2. I will be reading from a huge database, so it is a priority here the performance of the Client-Server interaction, with a special mention for data parsing and for servlet vs php performance.
Any help would be greatly appreciated.
Android has built-in support for parsing JSON data with the use of JSONObjects and JSONArrays, so it would be a lot easier to handle data in that form, rather than handling servlets. Its even possible to directly receive the web service response as a JSONObject or JSONArray.
In general, web services in Android should be of the RESTful type. That's how Google seems to prefer it. That's why there's built-in support for JSON, but not for SOA or Servlets.
References:
1. Reasons for not directly write Servlets for creating a REST API.
2. Servlet vs REST.
i need to get a website (any website ) in json format to use it with android and json parser to get data and if possible that the website include images to be able to download data and images using json parser.
i have been searching about 2 days without any success, its my first time that i use json so i do know where to search and how to search.
what i need is a website to make a test on it that will be available in json format
anyone can help me ???
i will appreciate that.
Use http://www.jsontest.com/ to get JSON from that website.
Read there and for example if you call http://ip.jsontest.com/ you will get a JSON response as {"ip": "203.92.62.242"} then you can parse them in your android application.
For future readers :
Facebook programmers provide the json format for each request.
All you have to do is :
If the facebook page url is : http://www.facebook.com/youtube
To get json format of page, request this : http://graph.facebook.com/youtube
I suggest to read that :
Usually standard web service today provide data in at least two format: json and xml for each endpoint (url), you just add .xml or .json extension to the requested url.
But most of the time you don't have to do that, common web services today always provide json data because it's defined in RESTFul rules. If they dont, you can't get the json. The case is same for you, just ask the developer for API docs.
Hi all I m programming on an Android Application that should be able to send a complex object to c#.Net webservice so the problem is i can send a single object but i cant send a list of object , my question is how to send a list of objects to web service
for more detail or if u want my source code just inform me thanks for your support
My sugestion is, you can send the list of objetc in XML like a single string and in the server side you can get this string and transform in xml again. This works for me.
I have a model User in Rails app. It is restful with 7 actions in UsersController. When accessed using a browser,
GET http://mydomain.com/users/new
will get a form to fill information on the new user. What should an Android app get? Should it also get a html form, fill it then send back the html? Can it get a JSON response from the new action in UsersController or maybe skip this step all together? How should this work?
If Android app is a client of your backend service it should have its own layouts/forms etc. Then, after collecting all necessary information from user you can send a response to server using JSON, in example:
POST http://mydomain.com/users/new
{"name":"Anrnold","password":"I<3steroids"}
If you want to display custom form retrieved dinamically from server you can pass form's fields and generate form on android device programatically. But why would you want to do that?
Everyting you need to know about json is here: json.org. I also recomend Gson