2011-11-10 5 views
2

백그라운드에서 smsInterceptor를 사용할 수 있습니까? 서비스를 사용하려고하는데 작동하지 않지만 MessageReceived 이벤트에서 메시지를 보내지 않습니다.백그라운드에서 smsInterceptor?

'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 

이것은 아마도 잘못되었습니다. 어떻게해야하는지 알지 못했습니다. 서비스 모듈 스레드를 읽지 만 어디서나 나를 데려 오지 못했습니다 :/

답변

2

Android가 서비스를 종료하지 못하게하려면 Service.StartForeground를 호출해야합니다.

또 다른 옵션은 매니페스트 파일을 수정하고 SMS 용 인 텐트 필터를 추가하는 것입니다. 이 경우 안드로이드는 SMS가 도착하면 자동으로 서비스를 시작합니다.

+0

Hehe, 이제 고마워. 또한 MessageReceived xd 전에 smsint_를 넣는 걸 잊었습니다. 빠른 응답을 보내 주셔서 감사합니다. – Adam

관련 문제