I have data on a server which stores name and images.
I want to retrieve that from server and display in table layout on Android.
I wonder which is the best xmlparsing or json parsing for that purpose.
Is there any tutorial for that?
if($_REQUEST['mode']=="get")
{
$result = mysql_query("SELECT state,imageurl FROM `pic_upload`");
while($row = mysql_fetch_assoc($result))
{
$output=$row;
print(json_encode($output));
}
mysql_close;
}
using this i will get data from server but how to get data using xml parsing any one know
It seems that json_encode($output) will produce a JSON output, so you should use Android's JSON API (org.json).
A quite recent tutorial is located at http://www.androidhive.info/2012/01/android-json-parsing-tutorial/ (also showing how to put retrieved elements on a list), but you will find many simply googling for Android and JSON.
If it is a simple item and no huge list, the org.json packages that come with Android are perfect.
Have a look at that Tutorial from Lars Vogel to get started.
Related
I'm new here, give me a solution about json please.
I want to fetch json data to my app from url, and also want to update json data regularly without url change.
suppose, i want to show trending products in an activity, after one day i will change some products of that activity by changing data from json. after updating my json, url cant be change, cause doing update whole app regularly for changing url is not a good idea.
so, is this possible to update json data without changing url?
if yes, tell me please where can i store my json so that i can update t regularly.
or if you can provide any other better possible way to do this, please help me.
Thank you.
That's why we use the database
Basically you need a database o structure your data, then you fetch data from the database using PHP which gives you a Json response
Since you are using Android Studio tag here is a good tutorial on how to fetch data from database using PHP , Json response tutorial
First you gonna start with LocalHost , consider using Xampp , Then use web hosting
You create your database using PhpMyAdmin in LocalHost/phpMyAdmin and you read the data using PHP which return it in Json Format
Then migrate to Web Hosting , in PhpMyAdmin you can export your Database from your LocalHost and Import it in your WebHost/PhpMyAdmin , and you upload your Php files also
I searched almost every tutorials and never fiend a perfect example for a custom expendable listview, where parent node and child node data will fetch from web server using JSON array. Please help me anyone, atleast give me any proper tutorial link so that I can understand the whole process.
Download the zip from this link:
https://github.com/alessandroargentieri/AndroidToWebService
Inside there is an Android Application which asks for a JSON message from a PHP Web service which takes the data from a Database MySQL.
If you want to see the PHP page, it is at the end of MainActivity.java as a commented code.
I want to develop an android application which parses json data into some meaningful data sets and accordingly display them into the UI .
I need suggestions on how to go about it.
PS : i have 0 idea of the available options to chose , so different ways to do the same would help me a lot , since i am new to it
Thanks in advance
You can use gson for parsing the data together with some network library like volley or can use retrofit which provide direct parsing with the help of gson and other lib.
To accomplish this you first need to create some relevant Java pojo
For corresponding json dataset , so that you can use it .
You can generate pojo from this website very easily for any json data
http://www.jsonschema2pojo.org/
I am currently working on TFL based projects. And i want to parse the json file which is available in this link : http://countdown.api.tfl.gov.uk/interfaces/ura/instant_V1
So please help me out
This API is not standard JSON as written in the TFL API documentation. It us actually best parsed as CSV but watch out because I have found out that some responses are inconsistent where the first line might have 6 strings while the second might have 5 with the missing field not identified as an empty string but simply omitted. This way parsing with a CSV parser will lead to errors since you might never know what is omitted.
I have also searched for the solution and the best I could find was another API that gives standard JSON but only returns bus stop countdown via a stopCode request.
Use This Link To Access It.
http://countdown.tfl.gov.uk/stopBoard/75288
Im suprised as to why TFL uses this api for their own apps but not implement the public api to return good JSon like this one.
This API is not standard JSON as written in the TFL API documentation.so after get the content you may change that format. Use this link http://jsonlint.com/ it will validate your json format. so you can easily understand json format error
After get the content do this
JSONArray jArray = new JSONArray("["+ result.replaceAll("]", "],").toString() + "]")
now you get proper json array skip jArray 0th position this is - URA Version array.
It is not a single full JSON object, as per the TFL documentation. You treat each line as a separate JSON object. This way if/when you move to the streaming mode, you can continue to receive objects and interpreting them as they get streamed to you. Also you use the first element in the JSON array to determine how to process that particular line, or in some cases if you need to refresh the base data.
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