When the service is called from background to foreground, I can see the application Icon popping up into the upper notification area. It remains visible until the service code is completed ( until the Service.StopAutomaticForeground is called ) . This flashing icon can be annoying as it comes up even when there is nothing to be notified.
I think I resolved the issue calling the Service.StopAutomaticForeground almost at the beginning of the service code. I have noticed the code of the service is anyway executed till the end with no problems.
Someone knows if this is correct or if it can cause problems ?
See the code as it is now here below.
Thanks
I think I resolved the issue calling the Service.StopAutomaticForeground almost at the beginning of the service code. I have noticed the code of the service is anyway executed till the end with no problems.
Someone knows if this is correct or if it can cause problems ?
See the code as it is now here below.
Thanks
B4X:
Sub Service_Create
Service.AutomaticForegroundMode=Service.AUTOMATIC_FOREGROUND_ALWAYS '26+
End Sub
Sub Service_Start (StartingIntent As Intent)
Dim sec As Long = 1800
Dim dnext As Long = DateTime.Now + (sec * DateTime.TicksPerSecond) ' prossima chiamata
StartServiceAt(Me, dnext, True) 'schedule
If StartingIntent.IsInitialized=True Then
' do something
Try
If StartingIntent.HasExtra("android.intent.extra.ALARM_COUNT") Then
Service.StopAutomaticForeground ' <--------- HERE!!???
' Do something , it takes a while
End If
Catch
End Try
End If
Sleep(0)
Service.StopAutomaticForeground ' da Android target +26
End Sub