Communication between main firemonkey application and local service

  

I’ve got a Firemonkey application with a Local Android Service.

When the user opens it, he has to write something in a TEdit and when he clicks an OK button, the application starts the local android service :

FLocationServiceConn := TLocalServiceConnection.Create; // — android_service
FLocationServiceConn.StartService(‘LocationService’); // — android_service

The service sends user’s location to a remote server using a nethttpclient object.

The problem is that I need to send TEdit.Text info with the user’s location to the remote server (I need to know which is the user), so I need to pass that info to the service when it starts.

I haven’t found how to pass parameters to a local service. I have tried to create a file when the user clicks OK button (it works)

miau:=TStringList.Create;
miau.Text:=’test’;
miau.SaveToFile(TPath.Combine(TPath.GetDocumentsPath, ‘conf.txt’));

but when I try to read that file from the service, it crashes…(It seems TPath is the problem).

What do you think? Which would be the best way to send the users info (TEdit.Text) to the local service?

Thank you very much

Comments are closed.