boten Active Member Licensed User Longtime User Oct 18, 2011 #1 I'm having problems using the PhoneEvents object. I have an activity and a service module. A1) When a button is pressed in the main activity - the service is started S1) When the service starts, it initialize PhoneEvent to monitor sending SMS then calls "Do_Send" in main A2) Do_Send send the sms (which the service should "capture") S2) when the SmsSentStatus event fires, it updates some global vars and calls "smsfollow" in main A3) smsfollow displays msgbox, stops the service and finish the activity. As it happens, the SMS is sent, but SmsSentStatus seems not to be fired. Attached is the project. Attachments phn.zip phn.zip 5.7 KB · Views: 688
I'm having problems using the PhoneEvents object. I have an activity and a service module. A1) When a button is pressed in the main activity - the service is started S1) When the service starts, it initialize PhoneEvent to monitor sending SMS then calls "Do_Send" in main A2) Do_Send send the sms (which the service should "capture") S2) when the SmsSentStatus event fires, it updates some global vars and calls "smsfollow" in main A3) smsfollow displays msgbox, stops the service and finish the activity. As it happens, the SMS is sent, but SmsSentStatus seems not to be fired. Attached is the project.
thedesolatesoul Expert Licensed User Longtime User Oct 18, 2011 #2 Can you use a ToastMessage instead of a MsgBox? Maybe modal dialogs cannot be displayed in the position you are in. Upvote 0
Can you use a ToastMessage instead of a MsgBox? Maybe modal dialogs cannot be displayed in the position you are in.
boten Active Member Licensed User Longtime User Oct 18, 2011 #3 Toast didn't help. The _SmsSentStatus never fired as there's nothing on the log from the event sub. Upvote 0
thedesolatesoul Expert Licensed User Longtime User Oct 18, 2011 #4 Looking at your code, it seems like the service has just died away. It processes Service_Create and Service_Start, and then it has nothing else to do, so it probably gets destroyed. Is it getting destroyed? ...sorry for asking questions, im not at my computer otherwise i would check myself Upvote 0
Looking at your code, it seems like the service has just died away. It processes Service_Create and Service_Start, and then it has nothing else to do, so it probably gets destroyed. Is it getting destroyed? ...sorry for asking questions, im not at my computer otherwise i would check myself
boten Active Member Licensed User Longtime User Oct 18, 2011 #5 ןthe process is destroyed when I press the back key (Activity Pause) Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Oct 18, 2011 #6 You should call Service.StartForeground to prevent it from being destroyed. Upvote 0
boten Active Member Licensed User Longtime User Oct 18, 2011 #7 pls explain. I pressed the back key after a very long wait for the service to do it's job (and fire the _SmsDelivered event). Only after a few minutes, when there's nothing on the log from the event, and needless to say, loooong after the SMS was received at the other phone, did I quit the app by the back key, thus destroying the service. Shouldn't the service fire the _SmsDelivered event (and put something on the log) once the SMS is sent? Upvote 0
pls explain. I pressed the back key after a very long wait for the service to do it's job (and fire the _SmsDelivered event). Only after a few minutes, when there's nothing on the log from the event, and needless to say, loooong after the SMS was received at the other phone, did I quit the app by the back key, thus destroying the service. Shouldn't the service fire the _SmsDelivered event (and put something on the log) once the SMS is sent?
Erel B4X founder Staff member Licensed User Longtime User Oct 19, 2011 #8 If you are stopping the service after the SmsSentStatus event then the SmsDelivered event will not be raised. You should only stop the service after SmsDelivered event is fired (if you want to stop the service). Upvote 0
If you are stopping the service after the SmsSentStatus event then the SmsDelivered event will not be raised. You should only stop the service after SmsDelivered event is fired (if you want to stop the service).
boten Active Member Licensed User Longtime User Oct 19, 2011 #9 I don't "care" about the SmsDelivered for now (no sub for it). What I'm worried is that the SmsSentStatus NEVER fires, even when the activity (and thus the service is working) is in foreground. The Log stmts in the SmsSentStatus do NOT produce any log output, also no log is produced from sub smsfollow (in main) which is called from the SmsSentStatus event sub. When and how is SmsSentStatus fired? Upvote 0
I don't "care" about the SmsDelivered for now (no sub for it). What I'm worried is that the SmsSentStatus NEVER fires, even when the activity (and thus the service is working) is in foreground. The Log stmts in the SmsSentStatus do NOT produce any log output, also no log is produced from sub smsfollow (in main) which is called from the SmsSentStatus event sub. When and how is SmsSentStatus fired?
Erel B4X founder Staff member Licensed User Longtime User Oct 19, 2011 #10 This is what I got when I ran your program: Code: Copy ** Activity (main) Create, isFirst = true ** ** Activity (main) Resume ** ** Service (smsmod) Create * service created ** Service (smsmod) Start ** service start service event 0123456789===OK...true service event, delivered=1 smsfollow going to stop service.... ** Service (smsmod) Destroy ** service destroy ** Activity (main) Pause, UserClosed = true ** Make sure that the phone library version is 1.60. Upvote 0
This is what I got when I ran your program: Code: Copy ** Activity (main) Create, isFirst = true ** ** Activity (main) Resume ** ** Service (smsmod) Create * service created ** Service (smsmod) Start ** service start service event 0123456789===OK...true service event, delivered=1 smsfollow going to stop service.... ** Service (smsmod) Destroy ** service destroy ** Activity (main) Pause, UserClosed = true ** Make sure that the phone library version is 1.60.
boten Active Member Licensed User Longtime User Oct 19, 2011 #11 note: Yesterday got the problems (b4a 1.6, phone 1.55), Today worked (b4a 1.7, phone 1.6) I got SmsSentStatus to work, but: I call smsmsg.Send twice in a loop with 2 different phone numbers in the main activity Code: Copy Dim smsmsg As PhoneSms Dim i As Int For i=0 To telmap.Size-1 smsmsg.Send(telmap.GetValueAt(i),mymsg) Log("do send to " & telmap.GetValueAt(i)) Next in the service I have: Code: Copy Sub zzz_SmsSentStatus(Success As Boolean, ErrorMessage As String, PhoneNumber As String, Intent As Intent) Log("service event " & PhoneNumber & "===" & ErrorMessage & "..." & Success) CallSub(main,"smsfollow") End Sub the log shows that the service event is called twice BUT with the same number (2nd number) Code: Copy do send to 11111111 <=== changed for posting here do send to 22222222 <=== changed for posting here service event 22222222===OK...true service event 22222222===OK...true The sms is sent to the 2 different numbers. Last edited: Oct 19, 2011 Upvote 0
note: Yesterday got the problems (b4a 1.6, phone 1.55), Today worked (b4a 1.7, phone 1.6) I got SmsSentStatus to work, but: I call smsmsg.Send twice in a loop with 2 different phone numbers in the main activity Code: Copy Dim smsmsg As PhoneSms Dim i As Int For i=0 To telmap.Size-1 smsmsg.Send(telmap.GetValueAt(i),mymsg) Log("do send to " & telmap.GetValueAt(i)) Next in the service I have: Code: Copy Sub zzz_SmsSentStatus(Success As Boolean, ErrorMessage As String, PhoneNumber As String, Intent As Intent) Log("service event " & PhoneNumber & "===" & ErrorMessage & "..." & Success) CallSub(main,"smsfollow") End Sub the log shows that the service event is called twice BUT with the same number (2nd number) Code: Copy do send to 11111111 <=== changed for posting here do send to 22222222 <=== changed for posting here service event 22222222===OK...true service event 22222222===OK...true The sms is sent to the 2 different numbers.
Erel B4X founder Staff member Licensed User Longtime User Oct 19, 2011 #12 note: Yesterday got the problems (b4a 1.6, phone 1.55), Today worked (b4a 1.7, phone 1.6) Click to expand... Please update us if your problem is solved... You will need to wait for the first message to be sent and then send the second one. Otherwise you will only get the status of the last sent message. Upvote 0
note: Yesterday got the problems (b4a 1.6, phone 1.55), Today worked (b4a 1.7, phone 1.6) Click to expand... Please update us if your problem is solved... You will need to wait for the first message to be sent and then send the second one. Otherwise you will only get the status of the last sent message.
boten Active Member Licensed User Longtime User Oct 19, 2011 #13 phone 1.6 seems to do the trick, event fired! Erel said: ... You will need to wait for the first message to be sent and then send the second one. Otherwise you will only get the status of the last sent message. Click to expand... Ok, gotcha, thx Upvote 0
phone 1.6 seems to do the trick, event fired! Erel said: ... You will need to wait for the first message to be sent and then send the second one. Otherwise you will only get the status of the last sent message. Click to expand... Ok, gotcha, thx
boten Active Member Licensed User Longtime User Oct 19, 2011 #14 sending the SMSs one-by-one and waiting for the event works fine, thx. Another question on the subject: Code: Copy Dim c As PhoneCalls Dim s As PhoneSms StartActivity(c.Call("0123456789")) s.Send("0123456789","hello there") the phone call is shown later on the phone's call log, but there's no sign of the SMS sent in "messaging" application, why? Upvote 0
sending the SMSs one-by-one and waiting for the event works fine, thx. Another question on the subject: Code: Copy Dim c As PhoneCalls Dim s As PhoneSms StartActivity(c.Call("0123456789")) s.Send("0123456789","hello there") the phone call is shown later on the phone's call log, but there's no sign of the SMS sent in "messaging" application, why?
D Deleted member 103 Guest Dec 3, 2011 #15 Hi boten, sending the SMSs one-by-one and waiting for the event works fine, thx. Click to expand... Erel wrote: You should call Service.StartForeground to prevent it from being destroyed. Click to expand... I do not know how it works, how you did it? Ciao, Filippo Upvote 0
Hi boten, sending the SMSs one-by-one and waiting for the event works fine, thx. Click to expand... Erel wrote: You should call Service.StartForeground to prevent it from being destroyed. Click to expand... I do not know how it works, how you did it? Ciao, Filippo
C cmweb Active Member Licensed User Longtime User Mar 29, 2012 #16 boten said: sending the SMSs one-by-one and waiting for the event works fine, thx. Click to expand... Could please someone explain, how to do that? For example, the app has to send 3 SMS to three different phone numbers. After sending the first, how can I manage that the app waits for the SMSsent event before continuing with the next SMS send job? Thanks, Carsten Upvote 0
boten said: sending the SMSs one-by-one and waiting for the event works fine, thx. Click to expand... Could please someone explain, how to do that? For example, the app has to send 3 SMS to three different phone numbers. After sending the first, how can I manage that the app waits for the SMSsent event before continuing with the next SMS send job? Thanks, Carsten
Erel B4X founder Staff member Licensed User Longtime User Mar 29, 2012 #17 You should use a process global variable that will hold the current state. For example you can have a List with the messages that you want to send. Then in SMSSent event you should check the list and if it is not empty send the next message and update the list. Upvote 0
You should use a process global variable that will hold the current state. For example you can have a List with the messages that you want to send. Then in SMSSent event you should check the list and if it is not empty send the next message and update the list.
C cmweb Active Member Licensed User Longtime User Mar 29, 2012 #18 Erel, Thanks, that will help! Best regards, Carsten Gesendet von meinem GT-N7000 mit Tapatalk Upvote 0