Android Question Is this 'bad practice'


Licensed User
Longtime User
I have an sms app underway that uses a service. Without going into detail, my preference is to have the service always running, but it does sometimes get killed. I can live with that but have looked at alternates to keep it alive and have tried (successfully) the following approach.
Using the Phone library I now also start the service when a phone call is either received or made, as well as the desired method of when an sms message is received.

The thought here is that it now gives the app three different intents to listen for that would restart the service if it fails.
While maybe not the ideal situation I wonder what the general feeling is on this approach. Is it 'acceptable' or 'totally bad' practice.


Licensed User
Longtime User

Hi Erel
I have seen that one and did already have service.startforeground in my code, but it still seems to stop occasionally.
I have added the start_sticky and will see how that goes.
I now have the following in my service module. (have removed other non related lines in this sample).
Is the following code look correct?

#Region Service Attributes
#StartAtBoot: true
#End Region

'Service module
Sub Process_Globals
Dim SI As SmsInterceptor
Dim sNotif As Notification
End Sub

Sub Service_Create
SI.Initialize2("SI", 999999)
sNotif.Icon = "icon"
sNotif.SetInfo("MyApp","Service Running",Main)
sNotif.Sound = False


End Sub
Upvote 0