簡單三步驟輕鬆完成四種 Android 系統服務 框架設計
RAD Studio 10 Seattle 四種 Android 系統服務
(1)Local Service。
(2)Intent Local Service。
(3)Remote Service。
(4)Intent Remote Service。
原廠 Android 系統服務說明展示,可以觀看下列影音資料:
RAD Studio 10 Seattle - Android Services
https://www.youtube.com/watch?v=xZvUqoASPdY
Local Service:
TAndroidServiceDM = class(TAndroidService)
function AndroidServiceBind(const Sender: TObject;
const AnIntent: JIntent): JIBinder;
procedure AndroidServiceConfigurationChanged(const Sender: TObject;
const NewConfig: JConfiguration);
procedure AndroidServiceCreate(Sender: TObject);
procedure AndroidServiceDestroy(Sender: TObject);
function AndroidServiceHandleMessage(const Sender: TObject;
const AMessage: JMessage): Boolean;
procedure AndroidServiceLowMemory(const Sender: TObject);
procedure AndroidServiceRebind(const Sender: TObject;
const AnIntent: JIntent);
function AndroidServiceStartCommand(const Sender: TObject;
const Intent: JIntent; Flags, StartId: Integer): Integer;
procedure AndroidServiceTaskRemoved(const Sender: TObject;
const ARootIntent: JIntent);
procedure AndroidServiceTrimMemory(const Sender: TObject; Level: Integer);
function AndroidServiceUnBind(const Sender: TObject;
const AnIntent: JIntent): Boolean;
Intent Local Service:
TAndroidServiceDM = class(TAndroidIntentService)
function AndroidIntentServiceBind(const Sender: TObject;
const AnIntent: JIntent): JIBinder;
procedure AndroidIntentServiceConfigurationChanged(const Sender: TObject;
const NewConfig: JConfiguration);
procedure AndroidIntentServiceCreate(Sender: TObject);
procedure AndroidIntentServiceDestroy(Sender: TObject);
procedure AndroidIntentServiceHandleIntent(const Sender: TObject;
const AnIntent: JIntent);
function AndroidIntentServiceHandleMessage(const Sender: TObject;
const AMessage: JMessage): Boolean;
procedure AndroidIntentServiceLowMemory(const Sender: TObject);
procedure AndroidIntentServiceRebind(const Sender: TObject;
const AnIntent: JIntent);
procedure AndroidIntentServiceTaskRemoved(const Sender: TObject;
const ARootIntent: JIntent);
procedure AndroidIntentServiceTrimMemory(const Sender: TObject;
Level: Integer);
function AndroidIntentServiceUnBind(const Sender: TObject;
const AnIntent: JIntent): Boolean;
Remote Service:
TAndroidServiceDM = class(TAndroidService)
function AndroidServiceBind(const Sender: TObject;
const AnIntent: JIntent): JIBinder;
procedure AndroidServiceConfigurationChanged(const Sender: TObject;
const NewConfig: JConfiguration);
procedure AndroidServiceCreate(Sender: TObject);
procedure AndroidServiceDestroy(Sender: TObject);
function AndroidServiceHandleMessage(const Sender: TObject;
const AMessage: JMessage): Boolean;
procedure AndroidServiceLowMemory(const Sender: TObject);
procedure AndroidServiceRebind(const Sender: TObject;
const AnIntent: JIntent);
function AndroidServiceStartCommand(const Sender: TObject;
const Intent: JIntent; Flags, StartId: Integer): Integer;
procedure AndroidServiceTaskRemoved(const Sender: TObject;
const ARootIntent: JIntent);
procedure AndroidServiceTrimMemory(const Sender: TObject; Level: Integer);
function AndroidServiceUnBind(const Sender: TObject;
const AnIntent: JIntent): Boolean;
Intent Remote Service:
TAndroidServiceDM = class(TAndroidIntentService)
function AndroidIntentServiceBind(const Sender: TObject;
const AnIntent: JIntent): JIBinder;
procedure AndroidIntentServiceConfigurationChanged(const Sender: TObject;
const NewConfig: JConfiguration);
procedure AndroidIntentServiceCreate(Sender: TObject);
procedure AndroidIntentServiceDestroy(Sender: TObject);
procedure AndroidIntentServiceHandleIntent(const Sender: TObject;
const AnIntent: JIntent);
function AndroidIntentServiceHandleMessage(const Sender: TObject;
const AMessage: JMessage): Boolean;
procedure AndroidIntentServiceLowMemory(const Sender: TObject);
procedure AndroidIntentServiceRebind(const Sender: TObject;
const AnIntent: JIntent);
procedure AndroidIntentServiceTaskRemoved(const Sender: TObject;
const ARootIntent: JIntent);
procedure AndroidIntentServiceTrimMemory(const Sender: TObject;
Level: Integer);
function AndroidIntentServiceUnBind(const Sender: TObject;
const AnIntent: JIntent): Boolean;