I have an Android app with some data (consisting in latitude and longitude) and a RAILS web service with a MySQL database... I want to know how to send this data to my database
You need an web server with logic implementation to accept/update/delete data from mysql server either by using Java/PHP etc...You need to specify internet permission in your manifest file. And follow the link below for more detail how to make PHP server sends data to an Android device
Rails exposes REST APIs that you can use to send data to your server. There should be an api that accepts post requests and updates the data on your web application's database. Ask your rails developer for the url.
Make a REST post/put call to your webservice.You can use Android httpclient to make a connection. The api is available here
http://developer.android.com/reference/android/net/http/AndroidHttpClient.html
As always, don't forget to turn on your internet permission and perform your network tasking within AsyncTask or another thread to prevent UI thread blocking.
Related
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
I wanted a background service that listens for data from XAMPP server. I don't want the app to make HTTP requests to check data in the server periodically, instead i want to have an event in the app that gets invoked along the data from the server. This question may seem vague but can anyone suggest me from where to start?? I will be very thankful.
You can use Node.js with express and socket.io, its easy to install and for usage. But also you can use online socket services. And for MySQL querys you can use Sequelize.
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.
I want to create client-server GPS tracking application that clients send location data to server and server saves them on database and show clients location fleet location for site users and give report for them.
In this application i don't know which method i can use.Client applications is android apps and server application is web based application.
Methods for send data from clients to server:
1)Consume web service in clients and send data to server by means of web service
2)Use MQTT in client application and send data with MQTT
in 1st method because data is little when a web service want to send that data to server use XML and this can increase data sizes! and web server for obtain location data first need to decompress them and get location data from web service package that this can use server resources!.But method 2st send location data direct to server but hard to implement and encoding!
which of the methods you offer for me to use in this application?
another concern is if i want to scale this application for other client side platforms like iphone which of above methods is optimum
Have you thought on using a REST service instead ?
So your tracking device will basically just call a REST url and POST data to it.
No overload of data size or compression.
Same REST service can be consumed by an Android or iPhone app.
Project Description: I have to make an application in android which gets the Latitude and Longitude from GPS and forward their location with identification to server. On the server end there should be web page which continuously receives the messages from the Android application and shows the location on Google maps.
Suppose there are 10 Android devices at different places in which our application is running. On the Server end we have to show 10 markers on Google maps at the location of devices.
What I have Done: I have made an application in android which gets Lat and Long from GPS. I'm familiar with socket programming on android. I've implemented the web page on the server end which has Google maps and shows the markers.
Confusion:
How can I make a server?
How can I transfer data from Android to server and what application required at server end which receive the data from Android. Is any desktop or console application needed which bind it-self at particular port of server, or web page is enough for me to achieve this target.
What protocol do I have to use? UDP, TCP/IP, or use the HTTP or HTTPS steam directly?
I just need some direction about my problem because I have never worked in Android and Client Server Communication. If you think this question is vague then please recommend a book about networking or any which you think is suitable for this type of problem.
A common setting can be like this:
Have following things:
A file (PHP) at server's end, whose sole purpose is to inject the data (lat,lng) received from android devices into a MySql database
A file (PHP) at server's end whose sole purpose is to fetch you the data (lat,lng) from the MySql databse. This file should receive a timestamp as its argument and return all the values of lat,lng who have been saved after that timestamp (For this, your database must store timestamp)
A file (HTML+JS) which just handles the map thing, has an AJAX call implemented which polls the second file at regular intervals with a timestamp value to get new lat,lng values. and when it gets the values, it plots them on the map
On the Android devices, make your app in a way that it keeps sending its location to the first PHP file at a particular time interval.
This way, you get what you wanted.
On the other note, If we talk about client-server architecture, a client sends the request and gets the response. that's it. for this, client accesses a server side script to get those responses. same way, your android app accesses a particular server side script and gets the response. That's it.
In the case when you want to implement server initiated communication to android, you'll have to use push mechanism, like Cloud to Device Messaging (C2DM)
Cheers.
Afaik...
First you need to get the data of GPS by using Location baser services provided in Android SDK(See Location MAnager, Location Listener etc etc...)
Confusion:- The confusion is that
How can I make a server.
Ans: Cant help you with this because i m not expert at configuring servers
How to transfer data from Android to server and what application required at server end which receive the data from Android. Is any desktop or console application needed which bind it-self at particular port of server, or web page is enough for me to achieve this target.
Ans: You can transfer the data that consists of the Latitude and Longitude using a webservice that recieves the data using get or post methods and then dumps it into your database every time the OnLocationChanged method is called on Location Listener. Preferably u can configure a mysql database in your server and then use it for your data storage. The web page you need to design in such a way that it frequently gets the location related data from the database and then display markers accordingly.
What protocol which I have to use UDP or TCP/IP, or use directly the HTTP or HTTPS steam?
Ans: If you are aware of php then u can use REST services or if you are .Net kind of guy you can use a SOAP webservice that uses simple http post methods to update data to the server.
Hope this helps.