I have a service that uses SMSIntercept to catch incoming text messages and to trigger a notification.
I want the main activity to open up and display the text in a big label or edittext when the user presses on the notification.
I'm having trouble with the activity opening and displaying the message.
Here is the Activity Module
And here is the Service Module
I haven't found any example that seem to fit.
Any help would be most appreciated.
Thanks.
I want the main activity to open up and display the text in a big label or edittext when the user presses on the notification.
I'm having trouble with the activity opening and displaying the message.
Here is the Activity Module
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim lblMessage As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("layoutMain")
PopUp_TextMsg
End Sub
Sub Activity_Resume
SMS_Start
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub SMS_Start
If SMSTest.servicerunning = False Then
StartService(SMSTest)
SMSTest.servicerunning = True
ToastMessageShow("VIT-SMS is running in background", True)
End If
End Sub
Sub PopUp_TextMsg()
Activity.BringToFront
lblMessage.Text = SMSTest.mFrom & CRLF & CRLF & SMSTest.mText
Msgbox(SMSTest.mText, SMSTest.mFrom)
End Sub
And here is the Service Module
B4X:
'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 servicerunning As Boolean
Dim notification1 As Notification
Dim smsInt As SmsInterceptor
Dim mFrom As String
Dim mText As String
End Sub
Sub Service_Create
smsInt.Initialize2("smsInt", 999)
notification1.Initialize
notification1.Icon = "icon"
notification1.Vibrate = True
notification1.Sound = True
Log("Service initialized")
End Sub
Sub Service_Start (StartingIntent As Intent)
StartServiceAt("", DateTime.Now + 10 * DateTime.TicksPerSecond, True)
Log("Service Started")
End Sub
Sub Service_Destroy
smsInt.StopListening()
End Sub
Sub smsInt_MessageReceived (From As String, Body As String) As Boolean
Log("Message Received From: " & From)
mFrom = From
mText = Body
notification1.SetInfo("From: " & mFrom, mText, Main)
Return False
End Sub
I haven't found any example that seem to fit.
Any help would be most appreciated.
Thanks.