问题
I'm pretty new in the android world. I am wondering how can I get the position of my friends and display it on a map. More precisely, I don't know how to share the position of my friends and I. Maybe have to use a server or something like that ?
Is it hard to code ?
Thx,
Arnaud
回答1:
You can look at existing open source solutions.
Here is a server side source code: https://github.com/tananaev/traccar/
And here is Android app: https://github.com/tananaev/traccar-client-android
Communication is done over TCP connection.
- After establishing connection client sends identification message:
$PGID,123456789012345*0F\r\n where 123456789012345 is a unique device identifier, in this case IMEI
- Then client sends location reports with selected interval in standard NMEA RMC format:
$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A
回答2:
Step-1 Create android app which will share required details like position and name etc and will request to the server for required information
Step-2 Create a server which will store the details sent by the user and sent necessary information to the appropriate client
Approach
When your friend will come online the app should send(installed in your friends device) the detail to the server whenever you want the information your app should request to the server for necessary information
回答3:
Is it hard to code ?
No it is not hard to code.
how can I get the position of my friends and display it on a map. More precisely, I don't know how to share the position of my friends and I. Maybe have to use a server or something like that ?
Yes you need a web server. In order to send information between two mobiles you need a web server which can transfer your information. Now your Precise location can be found using GPS and also you can use cell tower location (but it is not precise). Now Gps will return Latitude and Longitude of any location, all you need to send these lat/longs over your web server to your respected mobile device and all you left with displaying them on map.
Tutorial on Maps.
来源:https://stackoverflow.com/questions/19900401/real-time-sharing-of-gps-location