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