Best practice for android to send a text string to server -


i making real-time location tracker android app. yes there lot of duplicate questions here scenario. device's latitudes , longitude changing continuously, have send data @ server every 2 seconds.

http://myserver.com/tracker.php?lat=10&long=5&guid=123456

on other side device fetching location continuously every 2 second

http://myserver.com/getlocation.php?guid=123456

i new in android development googled gcm, bacground services , asynctask. battery drain not issue now. , concerned background services too. best approach send , fetch data every 2 seconds ? using asynctask or else ?

it depends, if server knows devices should fetch data, can best use google cloud messaging, though there might small delay not like. if want poll data in devices use separate thread (or asynctask thread wrapper code).

additionally can use long polling see this question insight that. on server side, , still requires thread in app. inside separate thread can use runonuithread update user interface, or use success , progress functions of asynctask


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -