我试图从“Androidapi.JNI.App.pas”(TJservice)扩展一个类/接口,我需要扩展这个类来提供服务。可能吗?如何?
我需要覆盖这样的方法:oncreate、onbind、ondestroy。但我不知道怎么做。
我试过这样的事情:
type Tandroidservice= class(TJService)
function onBind(intent: JIntent): JIBinder; override;
procedure onCreate; override;
procedure onDestroy; override;
procedure onStart(intent: JIntent; startId: Integer); override;
end;
出现此错误:
[DCC Error] Unit1.pas(13): E2137 Method 'onBind' not found in base class
[DCC Error] Unit1.pas(14): E2137 Method 'onCreate' not found in base class
[DCC Error] Unit1.pas(15): E2137 Method 'onDestroy' not found in base class
[DCC Error] Unit1.pas(16): E2137 Method 'onStart' not found in base class
[DCC Error] Unit1.pas(13): E2065 Unsatisfied forward or external declaration: 'Tandroidservice.onBind'
[DCC Error] Unit1.pas(14): E2065 Unsatisfied forward or external declaration: 'Tandroidservice.onCreate'
[DCC Error] Unit1.pas(15): E2065 Unsatisfied forward or external declaration: 'Tandroidservice.onDestroy'
[DCC Error] Unit1.pas(16): E2065 Unsatisfied forward or external declaration: 'Tandroidservice.onStart'