0

Does anyone know how to get service ObjectID (JNI Object) or JService from TAndroidService in Delphi?

Thank you very much for your advice and answers.

KJAN
  • 227
  • 4
  • 15

1 Answers1

1

TAndroidService inherits from TAndroidBaseService, which has a property called JavaService of type JService. So something like:

uses
  Androidapi.JNI.App;
...
var
  ServiceIntf: JService;
...
ServiceIntf := MyService.JavaService;

If you want the JNI object, try casting JavaService as ILocalObject and calling the GetObjectID method:

uses
  Androidapi.Jni;
...
var
  ServiceObjectID: JNIObject;
...
ServiceObjectID := (ServiceIntf as ILocalObject).GetObjectID; // gets the JNI ObjectID
blong
  • 2,145
  • 13
  • 23