Search the Community
Showing results for tags 'service'.
Found 2 results
-
Delphi Android service was stopped after closing the android application
Sathiya89 posted a topic in Cross-platform
I have used Delphi 12 for developing Android application and I'm trying to Service which needs to runs in the background to receive the frequent messages from Server using TCP sockets to displays the notifications. But, the service is deactivated / closed after the main process application is closed. Below, the code is mentioned the code to start the service : procedure TForm1.ButtonServiceStartClick(Sender: TObject); var ServiceIntent: JIntent; begin ServiceIntent := TJIntent.Create; ServiceIntent.setClassName(TAndroidHelper.Context, StringToJString('com.embarcadero.services.MyService')); TAndroidHelper.Context.startService(ServiceIntent); end; and also, I have added the following service information in AndroidManifest.template.xml : <service android:enabled="true" android:exported="false" android:label="MyService" android:process=":remote" android:name="com.embarcadero.services.MyService"> </service> Code in Service: function TDM.AndroidServiceStartCommand(const Sender: TObject; const Intent: JIntent; Flags, StartId: Integer): Integer; begin Result := TJService.JavaClass.START_STICKY; end; I have tried to use this Solution, but not able to compile. And tried to implement the Sleep in Android Start command / run the thread, still the android service is getting closed. Do, I need to mentioned the different flag for starting the service or do I need to add additional code to run the service all the time or can we restart the service once it's destroyed and how to handle the code in Destroy event? -
As in different old topics written, it is still not possible to have a android service with a tfdconnection or a tsqlconnection on it. The service is not starting any more, you use this. Here's a link: https://forums.embarcadero.com/thread.jspa?threadID=229761 But what can we do? Is there a known solution? I'm not able to find one. Have tried to create all components in service's code but still, i don't even get a log entry that means the service still can't be created and the app hangs on trying to start the service. Anone out there who can give some tips?