Proper way to communication between android app with php - android

iam making a location based app in android in which iam communicating with a server and giving some data to server now in android ican communicate with a php using DefaultHttpClient ,HttpPost/HttpGet and Http Response class in this simple way ican take and give data to web server and another way is to make a Rest webservice my question is which is the preferable way to communicate.

Related

is an android API essentially just using GET/POST to get information?

I'm trying to get the root of an API and I'm just wondering if most APIs are essentially using GET/POST requests to send and receive information?
My thought is that anything that android does with an API has to connect to some server somewhere, but is there a connecting language between the server and android? or can it essentially be explained like Android is sending a GET/POST request to a PHP page that makes calls to a database (if a database is involved)?
Example. If I'm very comfortable with php, can I make an API that references the php page?
yes u can use php or there is some backend providers that offer alot of good stuff
backendless or parse.com
but if u already have your php services dame u can use them by the HTTPRequests / HTTPResponses using this in some asynch task will make it eazy

how to use Apache at my Android App

I want to read and update data from server (using Apache) to my Android App.
I`m new at the Apache part.can anyone give me a guide for this kind of operation? I already download "XAMPP", and my main goal is to read a JSON into my App, but I believe I can manage also with php .
I know that this is general question but I don't understand at this subject.
Thanks.
the most basic way is to make sure your web server is listening on an open port(usually 80). in your android app send a request to your webserver (url request). on your server hava a script that echos or prints JSON data...
Apache is a web server. You need to connect to it using HTTP. There is an HttpClient and other ways to get http server data, as long as you have a network connection.

How to connect Android App connecting to a web service

I created a small app and with this app I want to send the data (over wifi or bluetooth) to a PC/server.
I am thinking of creating a webservice that will run on the PC and will be listening constantly to any incoming client requests.
Once it receives request from client, the data transfer takes place.And after the webservice receives the data it should automatically open an application/GUI window showing the data received.
My question is Can I create a webservice using TCP/IP in JAVA and have it constantly run in background and listening to client request?
Also how do I start a GUI as soon as the webservice detects a client request and receives the data?
Use SQL Server to manage the data on your desktop and create a web-service in .NET on Visual Studio.
Then connect to the web-service in your application and set/get data from the DB, using web-services.
Links which might be useful :
How to make a web-service in .NET (does not include the implementation in Android) : http://srikanthtechnologies.com/blog/dotnet/wsdaljava.aspx
How to connect your service with Android :
http://seesharpgears.blogspot.in/2010/11/basic-ksoap-android-tutorial.html
http://www.codeproject.com/Articles/304302/Calling-Asp-Net-Webservice-ASMX-From-an-Android-Ap
http://adrianandroid.blogspot.in/2012/05/access-c-net-web-service-in.html
the best way is to create a web service and connect your application to the web service, you can use the tool http://www.wsdl2code.com that create all the needed code for connecting and parsing the data :)
I recommend to use WS on the server-side and you can use Ksoap android library on the client-side. Create a background thread which updates the UI with the new data with. Use AsyncTask, Loader or Handler which is fit for your solution. (Read the official reference for more info).
you can easily achieve this by creating an end-points/routes using node.js or php then host it on the cloud. I think I like firebase for hosting for now, u might wonna try that it really cool. after creating those endpoint which will be connected to ur database then u use http get or post request depending on what u want from ur database in ur mobile app.
if u are creating for android use Retrofit for http connection.

How to perform client-server communication with android app? Can I use servlet on server side or do I need to implement web service?

I am developing an android app where a user has to enter his login details for authentication...the app will then check username and password entered by user on server and will act accordingly..so how to pass these login details to server..and do I need to implement web service on server side or can use servlet?
Can anyone please tell me which Web Service should I use for the above purpose...also I need to send other data from my client app to server, process it on server and give back the reply to client app...also how to implement a web service? Are there any tools for it? Any tutorials would be of great help.
Thanks in advance...
well, to send data to the server you can use HttpPost and HttpGet requests.
and as you need to get results from the server then, yes you'll need a web service.
You can use servlet (or) webservice, any service, as long as it can be accessed through URL. Make sure the servlet/webservice returning XML/JSON (one of these two formats are preferred, you need to code your servlet/service to return response in one of these formats) response when you hit the URL in internet explore. Once you make sure URL is returning data, then
1) In your app, using HTTPClient, invoke the URL
2) You will get either XML/JSON
3) If it JSON, use in buit JSONObject to parse the response and get the data
If response is XML, use either SAX/Dom parsing to parse the response.

android - client server programming

i need to develop an application for device management i am beginner in android and java. i want the client to send request for patch to the server and the server sends the requested and i also want to use web service to it. i wish to know how to lay connection between the individual android clients and the server. pls do send me some sample coding or tutorial???
i do not prefer doing it with php server Android PHP server
Since you don't want PHP and you specifically say you are using Android and Java, why not implement a servlet to host the patches. Then use HttpClient on the android side to send a request over to the servlet and have it respond with the patch.
More on servlets:
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/
And some simple code for HttpClient:
http://w3mentor.com/learn/java/android-development/android-http-services/example-of-http-get-request-using-httpclient-in-android/

Categories

Resources