Hi All,
OK I have being trying to avoid asking but I think I am now going round in circles, please tell me what I am doing wrong and why SI_MessageReceived do not appear to get called?
Manifest
Main
S1
Thanks Steve
OK I have being trying to avoid asking but I think I am now going round in circles, please tell me what I am doing wrong and why SI_MessageReceived do not appear to get called?
Manifest
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddPermission(android.permission.RECEIVE_SMS)
AddReceiverText(S1,
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>)
'End of default text.
Main
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim phone1 As Phone
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 Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Activity.LoadLayout("main")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
result = Msgbox2("Are you sure you want to exit","Alert","Yes","No","",Null)
End Sub
S1
B4X:
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim SI As SmsInterceptor
End Sub
Sub Service_Create
SI.Initialize2("SI",999) '2147483647
End Sub
Sub Service_Start (StartingIntent As Intent)
If StartingIntent.Action = "android.provider.Telephony.SMS_RECEIVED" Then
StartService("")
ToastMessageShow(" ---- ", True)
End If
End Sub
Sub Service_Destroy
StopService("")
End Sub
Sub SI_MessageReceived(From As String, Body As String) As Boolean
ToastMessageShow(From & " !!! " & Body, True)
Return True
End Sub
Thanks Steve