How to update marker positions in real time
I am creating an employee tracker where I will get all the Lat working current every 30 seconds and update it on the server, and then the Admin module will fetch the Lat-long of each employee from the server and update the token position.
So please tell me how to update the position of 100 markers without creating a UI thread in Android.
please help him is very important to me.
+3
source to share
1 answer
You can update your interface after every 30 seconds using a handler. Create a separate method that retrieves and displays the marker on the map.
Use the below code in your activity -
Handler UI_HANDLER = new Handler();
UI_HANDLER.postDelayed(UI_UPDTAE_RUNNABLE, 30000);
and below is the Runnable method which puts any place in your activity -
Runnable UI_UPDTAE_RUNNABLE = new Runnable() {
@Override
public void run() {
drawAllMarker();//Method that will get employee location and draw it on map
UI_HANDLER.postDelayed(UI_UPDTAE_RUNNABLE, 30000);
}
};
Hope this helps you.
+2
source to share