How to Create an API which gives response in JSON format - android

The website is already hosting on the server. I am trying to access data which is in PhpMyAdmin, into my android application.

you need to use any of networking libraries in android like Volley , retrofit , okHttp ... etc and learn how to decode JSON format then use this decode by any of networking libraries ,
you can use this library https://square.github.io/retrofit/
or use this library https://developer.android.com/training/volley

Related

Store WSDL file in Android Project and Parse this to create Retrofit API

i only have a .wsdl file locally and i only find examples for android to create a soap service with retrofit2 with an url. Now my question is what is best practice to store the .wsdl file in the project (is this a raw file?) and parse this for example with ksoap to create my api with retrofit? Any body some ideas?
The WSDL file is a webservice file, therefore it should seat on your server, you can deploy such webservices using Tomcat or JBoss applications. So you don't want to 'store' the wsdl file in your application, it should seat on your server. And you shouldn't 'parse' a wsdl file, its function is moving data from your client to server and viceversa. If doing what you are suggesting was possible(parsing with ksoap to create my api with retrofit), then it would be a bad programming practise due to redudancy. Retrofit works similarly to soap difference being retrofit makes use of JSON while SOAP makes use of XML. Try looking at my answer here Call a soap webservice in android to understand how android interacts with soap webservice

android web service insert database

I created a web site of travel with symfony2, I want to create mobile application using web services created in the web site, I get the data using jsonarry and jsonobject ,how I can insert data using my mobile application.
if there is good library.
thanks.
You can use Retrofit library, see below,
https://square.github.io/retrofit/
https://developer.android.com/reference/java/net/HttpURLConnection.html
you need to use httpurlconnection . you need not use libray for further use but if you want to deserialize and serialize json use GSON .
You can establish connection with web API's using okhttp and can parse json data using Gson library just add compile 'com.google.code.gson:gson:2.2.4' in your build.gradle and parse necessary using MVC method
Check this tutorial https://kylewbanks.com/blog/Tutorial-Android-Parsing-JSON-with-GSON

How to connect sql database to android application using wcf?

I currently use xmlstring to pass values between android application and sql server. But now i need to make this connection through wcf. so how can i do this one.
If your buliding the service, you might want to consider using Web api instead of wcf as it more simple to configure.
The basics of building an HTTP service using ASP.NET Web API
You can use a library as retrofit to get the data from the server.
Ater you fetch the data, in Json format, you can parse it using Gson

WebServices using ZendFramework 2

How to write RESTful WebServices to Android Application using ZendFramework 2?
The request and response data format is JSON only.
I recomend you to use : Zend Expressive, wich is the micro-framework from Zend, also is compatile with all Zend Framework modules and the most important part, and reason why I use it is because is very similar to Zend Framework 2
Take a look at Apigility, it's a lib to create RESTful API using ZF2:
https://github.com/zfcampus/zf-apigility

How to get some simple data by Internet in Android

I need to get some simple data (actual currency values) to my android application. I'm not sure what is the best way to achieve it. Do I have to make some database and put it on server and than update it manually or there is some better way?
You can use an API Service and access to this service from you android device. You donot need to do a server implementation for this.
e.g. for exchange rates check https://openexchangerates.org/
Yes.
Please make a server and a PHP which going to print out the values in JSON. You can validate your json with http://jsonlint.com/. After it you can download and parse the json with yourself or a 3rd part library (like retrofit).
You can use this website to generate POJO, so retrofit can parse the json for you by it`s own.
http://www.jsonschema2pojo.org/
select: JSON instead of scheme and select GSON instead of JSON, if you are using retrofit.
sources:
https://en.wikipedia.org/wiki/Gson
https://github.com/square/retrofit
http://blog.robinchutaux.com/blog/a-smart-way-to-use-retrofit/

Categories

Resources