Android Question toast when SMS received ?

Devv

Active Member
Licensed User
Longtime User
I'm trying to make a service that toast i got a message each time i receive an sms even if the app was not running

this is what i tried

Code: Copy
Sub Process_Globals

Type Message (Address As String, Body As String)
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.

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")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub Service_Start(startingIntent As Intent)
  If startingIntent.Action = "android.provider.Telephony.SMS_RECEIVED" Then
  ToastMessageShow("gow a new message",True)
  End If
end  sub



the mainfest file

Code: Copy
'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
AddPermission(android.permission.RECEIVE_SMS)
AddReceiverText(s1,
<intent-filter>
    <action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>)
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$")
'End of default text.



any ideas ?
 
@Erel
my code must be in a service module not in a activity module right ?
i'm getting this when i press F5

Code: Copy
Parsing code.                          0.06
Compiling code.                        Error
Module: s1_br not found.
 
Upvote 0
hi erel
im new to basic may you please take a look at the project , it is attached
 

Attachments

Upvote 0
Back
Top