2011-11-10 1 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

あなたのサービスを殺すのを防ぐため、Service.StartForegroundを呼び出す必要があります。

もう1つの方法は、マニフェストファイルを変更し、SMSのインテントフィルタを追加することです。その場合、SMSが到着したらAndroidが自動的にサービスを開始します。

+0

Heheさん、ありがとうございます。また、私はMessageReceivedの前にsmsint_を置​​くのを忘れたxd すばやい応答ありがとう。 – Adam

関連する問題