Search code examples
javaandroidgoogle-mapsgpsgeolocation

How to remotely track movement of android phone on map of a java desktop application using gps of android


I developed an android application in which shows the current location of the user and updates the movement on google map API 2 in that application. My requirement is to remotely track and draw the path of this android device on java application on desktop/laptop.

usage: Cab driver uses the android application. Cabs owner uses the desktop application.


Solution

  • You can easily archive that using the Google Maps Android API V2. Just send the current cab location LatLng values to your Java Application over a messaging & networking protocol. You can place the POST request in the setOnMyLocationChangeListener of the GoogleMap object.

    map.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
            @Override
            public void onMyLocationChange(Location location) {
                double lat =  location.getLatitude();
                double lng = location.getLongitude();
                //TODO: Send longitude and latitude to JAVA app
            }
        });