Jump to content
microtronx

Why i can't use TDSRestConnection in Rio and Android Service ... not starting any more

Recommended Posts

Hi Folks,

 

i'm new to Android Services world but have successful created my first app with a background-service (used demo of Kastrifree / CrossPlatformLocation) as base. It works good, but as soon i add a tfdconnection for a local sqlite table or a TDSRestConnection for connecting to a remote-server in the service-module it does not start.

 

My question is: What are the limits of a android-service-module created with Delphi Rio? What is blocking the service from starting if we add one of those components?

 

Edited by microtronx

Share this post


Link to post

I'm able to use FireDAC with SQLite OK in the demo you refer to. Can you provide a test project for the TDSRestConnection issue?

Share this post


Link to post

If i open the demo, select the service as active project and add a new clientmodule to a datasnap-server, save it and change the code in locationchangehandler to this:

 

procedure TServiceModule.LocationChangeHandler(Sender: TObject; const ALocation: TLocationCoord2D; const ASource: TLocationSource);
var
  LStatus: Integer;
begin
  // This is where to use the location data to update a server, or to a database when not connected to the internet and the data is to be sent later
  LStatus := 0;
  // Service in foreground means app is inactive
  if IsForeground then
	LStatus := 1;
  if FBackgroundMonitor.IsDozed then
	LStatus := 2;
//  FUpdater.SendLocation(ALocation, LStatus);


	try
		if locationClientModule.ServerMethodsClient.savelocation('hardwareidxx', aLocation.Latitude, aLocation.Longitude, lStatus, now())=true then begin
			toslog.d('savelocation REST OK');
		end;
	except
		on e:Exception do begin
			toslog.d('savelocation REST Error:'+e.message);
		end;
	end;
end;

plus add the locationclientmodule's unit to implementation/uses the module does not start any more, this is from logcat:

 

01-22 12:40:55.046  1491  1510 W ActivityManager: Timeout executing service: ServiceRecord{8ba5020 u0 org.xxxx.xxxx/com.embarcadero.services.xxxxLocationService}
01-22 12:40:57.623  1491  1510 E ActivityManager: Reason: executing service org.xxxx.xxxx/com.embarcadero.services.xxxxLocationService

 

I have also tried to add only a tfdConnection and a tfdQuery onto service-module and same problem, the service can't be started. the device i'm testing this is a Huawei P30-Lite with Android 9 on it. Possible that the problem is connected with this?

Edited by microtronx

Share this post


Link to post
5 hours ago, Dave Nottage said:

I'm able to use FireDAC with SQLite OK in the demo you refer to. Can you provide a test project for the TDSRestConnection issue?

 

Now i can note, that only adding the servermethodsclient's unit to implementation use clause is enough so the service is not starting any more. You don't have to use anything in your source.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×