Submitting a location to the Traccar Server from my custom android app.

Nikhil7 years ago

I am developing an android where I want to have a button on whose click event I want the users current location to be sent to the traccar server. The device is already registered on the server. I saw the API but their was no method to push the device location on the server. I am trying to dig the code in the traccar client app but not able to get much info right now.
If you can share the syntax of how the request will go from the click event of my button in the android app to the traccar server with a small snippet it would be really helpful for me.
Thanks.

Nikhil7 years ago

I got it to work on postman and on the web with this URL format:

http://demo.traccar.org:5055/?id=987615&lat=27&lon=32

Is this the same way I should be doing it on android as well using a GET request as I see that in the client app their is a databasehelper java class doing these things by communicating to the databases directly?

Anton Tananaev7 years ago

You can use GET, POST or any other method.

Traccar Client doesn't communicate with server database, if that's what you are asking. It has local database to store data when there is no internet connection.

Nikhil7 years ago

Thanks Anton for the response. I understand now. One more quick question if their is internet connection then also the location updates go to the offline databases only or to the server directly? Also is their any specific reason for this kind of workflow of offline database for client app.
Thanks.

Anton Tananaev7 years ago

They are sent immediately, if that's what you are asking.

mohammed shafeeq5 years ago

hi, in my project also i have same requirement. that is when a user press a the button from the app, the location should mark in different color. what i have to do for that ? which file i have to work with ? since i am new to android i am totally blank. any help please

Ujjwal kumar5 years ago

Hi Anton, I am trying to customize android traccar client app. i have one more button when user press that button then last known location and time should be sent on traccar server separately without affecting live location tracking system. is it possible by using traccar API. Thank you.

Anton Tananaev5 years ago

There is a SOS button that does exactly that.