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 s开发者_JAVA技巧erver 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.
精彩评论