Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android GPS Delay When Sending to Database

I have made an Android application that sends GPS coordinates to a PHP script (every second) which sends them to a database to be stored, and then a Javascript program pulls the coordinates (every second) and displays them on a map and tracks the user with markers and a polyline.

I'm having trouble with the reliability of the app, however. I tested it in my room and I'm able to receive the location updates just fine, but when I was in class today, the phone would not send the coordinates. I walked outside and immediately picked up a signal and my coordinates were sent and then received by the PHP script. Is there anything I can do about this or will I always have issues when inside large buildings? I'm using 2.2.3 if that helps at all.

Another issue I'm having is the time delay between when the button is pressed and when the coordinates are received by the PHP script. It takes about 20-30 seconds before the database records them. I send some other data to a different table and it gets to the db almost instantaneously. Could this be because I have so many programs that the coordinates must go through, or is the time delay to be expected since the phone must run more complex processes to obtain the coordinates? Is there anything I can do to reduce this delay time?

like image 439
mkyong Avatar asked Nov 13 '22 09:11

mkyong


1 Answers

You should debug your code on the client side (app) and on the server-side (php). Create a unique ID for every update "transaction" and print it on both sides:

* In the app - you can connect the device to the computer and use eclipse and add debug-printings. If you want to be able to get away from the computer - you'll have to print a log file on your android app

* On the server-side you can use microtime() and print the relevant ID with the time the request was received

like image 181
Nir Alfasi Avatar answered Nov 16 '22 03:11

Nir Alfasi