我有一个带有常规服务的应用程序,我用
StartService()
.
在服务的
OnStartCommand
事件中,我调用以下过程将其发送到前台。
但是,这样做会导致应用程序崩溃并变得无响应。
也许我跳过了一些步骤?
procedure TdmService.StartForeground;
var
LBuilder: JNotificationCompat_Builder;
begin
LBuilder := TJNotificationCompat_Builder.JavaClass.init(TAndroidHelper.Context);
LBuilder.setAutoCancel(True);
LBuilder.setContentTitle( StrToJCharSequence( 'Servizio avviato in Foreground' ) );
LBuilder.setContentText( StrToJCharSequence('Monitoraggio in Corso' ) );
LBuilder.setSmallIcon( TAndroidHelper.Context.getApplicationInfo.icon );
LBuilder.setTicker( StrToJCharSequence( 'Caption' ) );
Javaservice.startforeground(1413, Lbuilder.build );
end;