2

I want to start an Android service when the system boots up. I already read how to start an app here: http://dannywind.nl/auto-start-delphi-xe5-android-app-after-boot/ but me i don't want to start an app but a service.

how to do it ? I m under delphi Berlin

zeus
  • 12,173
  • 9
  • 63
  • 184
  • The same way you do for an app, just start the service instead, e.g the first answer, here: https://stackoverflow.com/questions/2784441/trying-to-start-a-service-on-boot-on-android – Dave Nottage Jul 09 '17 at 23:22
  • 1
    You must implement a `BroadcastReceiver` that handles the `BOOT_COMPLETED` broadcast to then run the service. Implementing a `BroadcastReceiver` in Delphi is not impossible, but it is not trivial, either. Look around, there are online tutorials that explain how to do it. – Remy Lebeau Jul 10 '17 at 04:19
  • ok, thank i will look around, seam their is no way to escape to build a custom jar for this – zeus Jul 10 '17 at 06:50

1 Answers1

0

If you don't want to create a custom jar/java this is how i did :

you will just need to update your android manifest with something like this :

  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

  <receiver android:name="com.alcinoe.content.ALStartServiceBroadcastReceiver">  
    <intent-filter>  
      <action android:name="android.intent.action.BOOT_COMPLETED" />  
    </intent-filter>  
  </receiver>
  <meta-data android:name="com.alcinoe.startServiceName" android:value="com.embarcadero.services.myService"/>   

and add the alcinoe.jar (https://svn.code.sf.net/p/alcinoe/code/)

that all you will need to do :)

zeus
  • 12,173
  • 9
  • 63
  • 184