Timer is not working inside service

Shay

Well-Known Member
Licensed User
Longtime User
Hi

I have the following 2 problems
1. my app need to call some number, soon after I receive SMS with the details (running as a service) , but as soon as the SMS is arriving the dial process begins and terminate, without finish the call (it is like you dial and cancel the call)
so i tried to overcome by adding timer (I tought maybe this is race problem)
and now second problem
2. timer is not working inside the service - getting error of force shuting my app

Can you help with first problem - so I will know why, and with solution (maybe the second problem is the solution)

here is the code

Sub SI_MessageReceived (From As String, Body As String)
MessageFrom1 = From
MessageBody1 = Body
Check_Arrived_SMS
End Sub

Sub Check_Arrived_SMS

StartActivity(PhoneCall.Call("0541234567"))

End Sub

-------Second problem - after trying to add timer ------
Sub SI_MessageReceived (From As String, Body As String)
MessageFrom1 = From
MessageBody1 = Body
Timer1.Enabled = True
End Sub

Sub Timer1_Tick

Timer1.Enabled = False
ToastMessageShow("Timer", False)
StartActivity(PhoneCall.Call("0541234567"))


End Sub
 
I dont think this is the case
I added code that when SMS arrive, it will open new activity, and there it will make the call
i am getting the same problem, while there is no more code to run

what to do?
 
Last edited:
Upvote 0
the phone is making the call and disconnect

how do I put logs? (never did it before)
 
Upvote 0
I am getting popup window, saying: (in hebrew)

sorry, your application (application anme) stopped unexpectedly try again

and getting button: force close

where else should I look?
 
Upvote 0
On your right on the B4A IDE, there are four tabs.
One of them is for Logs.
Press Connect on it for it to connect to the emulator/your device.
Then run the program.
If you do not see any errors, the check the unfiltered logs (there is a checkbox).
If you run into any problems with this, use the Search box in this forum to see how to make it work.
 
Upvote 0
Thanks (this was new to me)

there was no error while filtered
attached is the none-filter log
 

Attachments

Upvote 0
yes
I found the problem
I looked the the log and saw this:
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:100)

found another thread of b4a, and did some change
and it worked

Before the fix I declared the
Dim Timer1 As Timer
Timer1.Initialize ("Timer1",4000)
at the Sub Process_Globals (as it is also written in the other post)

I changed it to:
Dim Timer1 As Timer - under Sub Process_Globals
and Timer1.Initialize ("Timer1",4000) under Sub Service_Start

seems to solve the crash, I will check later if the phone is now calling ok

:sign0098: :sign0060:
 
Upvote 0
Back
Top