SMS send without notification message

magalt

Member
Licensed User
Longtime User
Hi all
With the code

Dim SmsOk As PhoneSms
SmsOk.Send(NumTel.Text, Msg.Text)
Msgbox ("The message was send", "Ok")

I can send SMS at NumTel.

Add today: with 'SmsOk.Send' I sent SMS and my provider sent me a notification message

The matter, with my provider, is the cost of notification message.

Exist a way, programmatically, for not require and receive this notification message?

Thanks
 
Last edited:

volvomann

Active Member
Licensed User
Longtime User
Check the unfiltered logs in this case.
Is this ok?
LogCat connected to: B4A-Bridge: Sony Ericsson SK17i-358216040490039
--------- beginning of /dev/log/system
finishReceiver called but no pending broadcasts
Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@2b31dc58
Setting rotation to 1, animFlags=0
Config changed: { scale=1.0 imsi=242/1 loc=nb_NO touch=3 keys=2/1/2 nav=1/1 orien=2 layout=18 uiMode=17 theme=ComponentInfo{com.sonyericsson.defaultruntimethemes/com.sonyericsson.defaultruntimethemes.BlueThemeService} seq=55}
No longer want com.facebook.katana (pid 9686): hidden #16
No longer want com.sonyericsson.usbux (pid 10160): hidden #17
Scheduling restart of crashed service com.sonyericsson.usbux/.service.UsbService in 5000ms
Scheduling restart of crashed service com.facebook.katana/.service.UploadManager in 5000ms
Start proc com.facebook.katana for service com.facebook.katana/.service.UploadManager: pid=12868 uid=10024 gids={3003, 1015}
Timeout of broadcast BroadcastRecord{2b5f3940 android.provider.Telephony.SMS_RECEIVED} - receiver=android.os.BinderProxy@2b4fd610, started 10003ms ago
Receiver during timeout: BroadcastFilter{2b4d7af8 ReceiverList{2b4d7a58 12784 pkk.hth.lfg/10128 remote:2b4fd610}}
ANR in pkk.hth.lfg
Reason: Broadcast of Intent { act=android.provider.Telephony.SMS_RECEIVED (has extras) }
Load: 7.09 / 7.15 / 7.15
CPU usage from 5538ms to 76ms ago:
2% 246/system_server: 0.9% user + 1% kernel / faults: 23 minor
1% 11046/tiwlan_wq: 0% user + 1% kernel
0.5% 12784/pkk.hth.lfg: 0.1% user + 0.3% kernel / faults: 48 minor
0% 48/spi_qsd.0: 0% user + 0% kernel
0.1% 115/rild: 0.1% user + 0% kernel
0% 116/zygote: 0% user + 0% kernel / faults: 17 minor
0% 315/com.android.systemui: 0% user + 0% kernel / faults: 1 minor
0.1% 11142/anywheresoftware.b4a.b4abridge: 0.1% user + 0% kernel
+0% 12868/com.facebook.katana: 0% user + 0% kernel
8.7% TOTAL: 4.9% user + 3.6% kernel + 0.1% softirq
CPU usage from 349ms to 866ms later:
21% 246/system_server: 13% user + 7.6% kernel / faults: 33 minor
3.8% 253/SurfaceFlinger: 1.9% user + 1.9% kernel
1.9% 250/Compiler: 1.9% user + 0% kernel
1.9% 258/GL updater: 0% user + 1.9% kernel
1.9% 271/ActivityManager: 0% user + 1.9% kernel
1.9% 391/Binder Thread #: 1.9% user + 0% kernel
1.9% 395/Binder Thread #: 1.9% user + 0% kernel
1.9% 808/Binder Thread #: 1.9% user + 0% kernel
+0% 12881/Thread-547: 0% user + 0% kernel
+0% 12882/Thread-548: 0% user + 0% kernel
 
Last edited:
Upvote 0

volvomann

Active Member
Licensed User
Longtime User
Her is the hole code

the main has 2 labels 2 edithtext and 2 buttons
Main

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 strPhoneNumber, strPhoneBody As String
   Dim Button1 As Button
   Dim EditText1 As EditText
    Dim bnr As String
   
   End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
StartService(callsms)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub MessageReceived
   strPhoneNumber = callsms.MessageFrom1
   strPhoneBody =   callsms.MessageBody1    
   Msgbox(strPhoneBody,strPhoneNumber)
  'StopService(callsms)
End Sub

Sub btnShow_Click
End Sub

Sub Button2_Click
   ExitApplication
End Sub



Sub Button1_Click
   Dim c As PhoneCalls
   Dim s As PhoneSms  
   bnr=EditText1.Text
   If bnr="" Then
   Msgbox("Ingen bilnummer","Test PKK")
   Else 
   SendSms("xxxxx", "message text...")
   
   's.Send("xxxxxx","regnr"& bnr)
   'startservice(callsms)
   End If
End Sub


Sub SendSms(PhoneNumber As String, Text As String)
    Dim ps As PhoneSms
    Dim r As Reflector
    r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getDefault", Null, Null)
    r.RunMethod4("sendTextMessage", Array As Object(PhoneNumber, Null, Text, Null, Null), _
     Array As String("java.lang.String", "java.lang.String", "java.lang.String", _
     "android.app.PendingIntent", "android.app.PendingIntent"))
End Sub

Callsms service

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    
Dim MessageFrom1 As String
Dim MessageBody1 As String
Dim si As SmsInterceptor
   
End Sub
Sub Service_Create
   si.Initialize2("si",999)
     
End Sub

Sub Service_Start
 
End Sub

Sub SI_MessageReceived (From As String, Body As String) As Boolean
    MessageFrom1 = From 'here we give the Process_global variable the value From. (From As String)
    MessageBody1 = Body 'here we give the Process_global variable the value Body. (Body As String)
    CallSub("Main","MessageReceived") ' I will explain this later.   
   ToastMessageShow(MessageFrom1, True)
   Return True
    
    'CallSub("Main","MessageReceived") ' I will explain this later.


End Sub
 
Upvote 0

volvomann

Active Member
Licensed User
Longtime User
I found the problem i can not call the mesagboks
in the sub Sub MessageReceived I have to use a button.
But how can then popupp the msgbox automaticly when the sms cam inn?

B4X:
Sub MessageReceived
   strPhoneNumber = callsms.MessageFrom1
   strPhoneBody =   callsms.MessageBody1   
  Msgbox(strPhoneBody,strPhoneNumber)
End Sub
 
Upvote 0

volvomann

Active Member
Licensed User
Longtime User
The problem is that Android expects the broadcast to be handled in a quick manner.
You can use a short timer and show the message box form the timer event.

Thank you for your help. I solved problem with using a label insted off an msgbox it, Workes realy good.
And there no more notifications cost on my phone bill afther i add your code Thanks again
 
Last edited:
Upvote 0

pobss

Member
Licensed User
Longtime User
Please try this code and see if the notification message is sent:
B4X:
Sub SendSms(PhoneNumber As String, Text As String)
   Dim ps As PhoneSms
   Dim r As Reflector
   r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getDefault", Null, Null)
   r.RunMethod4("sendTextMessage", Array As Object(PhoneNumber, Null, Text, Null, Null), _
      Array As String("java.lang.String", "java.lang.String", "java.lang.String", _
         "android.app.PendingIntent", "android.app.PendingIntent"))
End Sub

Thanks Erel :sign0098:
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Hi there,
does it happen for all messages you send, or only for the messages you send
through your b4a app?
 
Upvote 0
Top