AkaiYon1003
Member
Good day!
I copied the example from this thread: https://www.b4x.com/android/forum/t...sms-messages-in-the-background.20103/#content
But I cannot get it to run. Please see and let me know where I did was wrong.
Here's the Manifest:
Here is the code:
And here is the error:
Error parsing manifest script:<br />Module readsmsservice_br not found (Manifest Editor)
SMS - 19: Object converted to String. This is probably a programming mistake. (warning #7)
Thanks!
I copied the example from this thread: https://www.b4x.com/android/forum/t...sms-messages-in-the-background.20103/#content
But I cannot get it to run. Please see and let me know where I did was wrong.
Here's the Manifest:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<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.
AddPermission(android.permission.RECEIVE_SMS)
AddReceiverText(readsmsservice,
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>)
Here is the code:
B4X:
Sub Process_Globals
Type Message (Address As String, Body As String)
End Sub
Sub Service_Create
End Sub
Sub Service_Start (StartingIntent As Intent)
If StartingIntent.Action = "android.provider.Telephony.SMS_RECEIVED" Then
Dim messages() As Message
messages = ParseSmsIntent(StartingIntent)
For i = 0 To messages.Length - 1
Log(messages(i))
Next
End If
Service.StopAutomaticForeground
End Sub
Sub Service_Destroy
End Sub
'Parses an SMS intent and returns an array of messages
Sub ParseSmsIntent (in As Intent) As Message()
Dim messages() As Message
If in.HasExtra("pdus") = False Then Return messages
Dim pdus() As Object
Dim r As Reflector
pdus = in.GetExtra("pdus")
If pdus.Length > 0 Then
Dim messages(pdus.Length) As Message
For i = 0 To pdus.Length - 1
r.Target = r.RunStaticMethod("android.telephony.SmsMessage", "createFromPdu", _
Array As Object(pdus(i)), Array As String("[B"))
messages(i).Body = r.RunMethod("getMessageBody")
messages(i).Address = r.RunMethod("getOriginatingAddress")
Next
End If
Return messages
End Sub
And here is the error:
Error parsing manifest script:<br />Module readsmsservice_br not found (Manifest Editor)
SMS - 19: Object converted to String. This is probably a programming mistake. (warning #7)
Thanks!