Show/Hide Toolbars

Android Applications

Navigation: Android Specifics > Android "Service"

Services and Globals Var

Scroll Prev Top Next More

Do not yet understand but have had issues.

 

When Compiling an application using a service the service is compiled and then the application is compiled.

 

If the Service Module is referred to  in the application it must be in the Application uses clause.

 

It seems there may be an issue with using Global Variables as the basis of singleton objects.

 

Eg

Var

   GlobalObject : TSingletomObject = nil ;

 

 

Function GetGlobalSingleton : TSingletomObject;

begin

if  GlobalObject = nil then

    GlobalObject : =TSingletomObject.Create ;

 

 Result:=GlobalObject

end;

 

 

Testing a passed pointer as an object type does not work from a service

 

Eg

procedure TLocationTrackingForm.ServiceConnected(const LocalService

 : TAndroidBaseService);

begin

//  if not (LocalService is TFBServiceModule) then     Exit; Always exits

 

 Service := TFBServiceModule(LocalService);

 

//  if not (AThread is TISTestServiceThread) then

//     Exit;