Android Question Android close my autoboot service

Espinosa4

Active Member
Licensed User
Longtime User
Hi,

Can you help me with this code, please?

The service is running during long time but finally android closes the service and it is closed until the phone rebooted.

Thank you.
 

Attachments

  • L4Notificaciones.zip
    22 KB · Views: 165

Espinosa4

Active Member
Licensed User
Longtime User
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
I presume that you are not placing an icon in the notification area (top of your screen). Either place an icon in the notification area or restart your service every 60 seconds or so...
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Hi LucaMs

I tried to do the sticky service but OS still kills and without execute again the code.
What could I do?

I have this lines in attributes

#Region Service Attributes1
#StartCommandReturnValue: android.app.Service.START_STICKY
#StartAtBoot: True
#End Region

I have read this right now:
Edit: Things have changed in Android 4.4.2. It is not clear if the changes are deliberate or not. Sticky services are not recreated any more: https://code.google.com/p/android/issues/detail?id=63793

So I think that there is only one "type" of service that will not be killed by Android, service that uses StartForeground.
 
Last edited:
Upvote 0

Espinosa4

Active Member
Licensed User
Longtime User
Hi everyone,

I am still fighting with the autoboot and notifications.
I am an amateur programmer and there're things which I don't undertand.

Can you help me please with this code?
Android finally close the service.

Cheers
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Don't use the starter service (it's a "special" B4A-service), use another one (just add one) and use

B4X:
Sub Service_Create
    sNotif.Initialize
    sNotif.Icon = "icon"
    sNotif.Vibrate=False
    sNotif.SetInfo2("MyService","Service Running","...",Main)
    sNotif.Sound = False
    sNotif.Notify(1)
    Service.StartForeground(1,sNotif)
End Sub

This will start your service as a ForegroundService which will be kept. Bad thing: There will be a notification.

Another hint: Your php call looks very fragile! Everyone can send a complete SQL-statement (even "Delete from listadocambios" which deletes the complete table).
 
Upvote 0

Espinosa4

Active Member
Licensed User
Longtime User
Don't use the starter service (it's a "special" B4A-service), use another one (just add one) and use

B4X:
Sub Service_Create
    sNotif.Initialize
    sNotif.Icon = "icon"
    sNotif.Vibrate=False
    sNotif.SetInfo2("MyService","Service Running","...",Main)
    sNotif.Sound = False
    sNotif.Notify(1)
    Service.StartForeground(1,sNotif)
End Sub

This will start your service as a ForegroundService which will be kept. Bad thing: There will be a notification.

Another hint: Your php call looks very fragile! Everyone can send a complete SQL-statement (even "Delete from listadocambios" which deletes the complete table).
Hi KMatle,

Thank you very much indeed for replying.
Thank youuu for your advises and your help.

I'll try to do it
Cheers
 
Upvote 0
Top