Android Question sms intent not triggering

gpa

Member
Licensed User
Longtime User
Hi...
I have a simple sms send / receive test program. The receive intent is as per https://www.b4x.com/android/forum/t...cepting-sms-messages-in-the-background.20103/
It works perfectly on one phone - Samsung S8, Android 9; but the intent fails to trigger on another phone - Huawei P20.
b4a v 9.50

Any suggestions as to how to debug this situation?

Thanks!

manifest:
...
AddPermission(android.permission.SEND_SMS)
AddPermission(android.permission.READ_PHONE_STATE)
AddPermission(android.permission.RECEIVE_SMS)
AddReceiverText(sms1,
<intent-filter>
    <action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>)

service module:
#Region  Service Attributes
    #StartAtBoot: 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.
    Type Message (Address As String, Body As String)

End Sub

Sub Service_Create
    Log("hello")
End Sub

Sub Service_Start (StartingIntent As Intent)
    Log(StartingIntent)
    ToastMessageShow(StartingIntent, True)
    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
'    Sleep(2)
    Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
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

Sub Service_Destroy

End Sub
 
Last edited:

gpa

Member
Licensed User
Longtime User
Good thought!
Tried it - but it didn't work.

Anyone know any third party sms receive apps I could try - as a reference, see if someone else has got it working on Huawei?
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
android:targetSdkVersion="26"
Try lowering to 24 and write what happens. Maybe Google has already completely blocked Huawei
 
Upvote 0

gpa

Member
Licensed User
Longtime User
Good thought - but makes no difference. SMS send works as does the whole play store so....
Something in the huawei phones seems to behave out of spec on sms receive.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Is the SMS app inside the hauwei device happen to be "Messages" by Google?
 
Upvote 0

gpa

Member
Licensed User
Longtime User
It's the baked in app.... Not sure who wrote it. Could well be derived from the google default, it looks and feels the same as the S8 app.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
The reason that I ask is that even though your app is not from the playstore, any "google" apps on that device require the "google services" framework and it's cloud servers for certain things to work right, and maybe somehow this google legal issue is effecting some apps on hauwei devices.

Another thing you can try, and this is a long shot, is that google messages (if that is even the app on these devices) is trying to switch over all SMS messages from communicating over the phone carrier's network to google's own servers (though the internet) so it can offer iMessage-like features such as typing activity "dots" and send receipts. So, if there is an option in the SMS program to turn off "Advanced Messaging", then maybe that might bring you some luck?
 
Last edited:
Upvote 0

gpa

Member
Licensed User
Longtime User
Hmm... there's no advanced option... And on all phones here SMS only works with cellular connection, or cellular provider wifi calling...
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
The below article explains how Google was getting impatient with carriers taking too long to support RCS, so Google created a work-around. So if you have Google "Messages" as your SMS app and are sending to someone who also has google messages install (and have this new feature enabled), it will NOT use the carriers SMS connections and instead go through google servers (through a data connection).


But in reading the article in more detail, there would be a clear option to turn this feature on, so since you don't see it, then the SMS app is probably not "Messages".

It was just a long short idea because your issue is very strange.
 
Upvote 0

gpa

Member
Licensed User
Longtime User
Yes, thanks - and interesting info!
I wonder if google will make that stick! Duo won't lat much longer I expect...

The huawei thing is frustrating. Must be something in EMUI that blocks the receive intent. I can't find any way to see what's happening, can't see anything in the phone logs either.
Considering a work around to try and copy it automatically from the phone's sms app to my app.
Or just tell all the customers to stick to LG or Samsung phones!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…