2

Is it possible to use the smsInterceptor in the background? I'm trying to use services for that but it won't work, it won't toast message the sms for me on the MessageReceived event.

'Service module
Sub Process_Globals 
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim smsint As SmsInterceptor
End Sub

Sub Service_Create
smsint.Initialize("smsint")
End Sub

Sub Service_Start (StartingIntent As Intent)
    StartServiceAt("", DateTime.Now + 30 * DateTime.TicksPerSecond, True)
End Sub

Sub Service_Destroy

End Sub

Sub MessageReceived (From As String, Body As String)
    ToastMessageShow(From & " - " & Body, True)
End Sub

This is probably wrong tho, I haven't figured out how to do it. Read the services module thread but didn't get me anywhere :/

Adam
  • 81
  • 3
  • 7

1 Answers1

2

You will need to call Service.StartForeground to prevent Android from killing your service.

Another option is to modify the manifest file and add an intent filter for the SMS. In that case Android will start your service automatically when an SMS arrives.

Erel
  • 1,802
  • 2
  • 15
  • 58
  • Hehe, works now thanks. Also I forgot to put smsint_ before MessageReceived xd Thanks for quick response. – Adam Nov 10 '11 at 20:38