Phone call in/out callback
Declaration
thread.register_event("xxtouch.call_callback", function(val)
if (val == "in") then
-- incoming call
elseif (val == "out") then
-- outgoing call
elseif (val == "disconnected") then
-- call disconnected
end
end)
States
- in
When an incoming call arrives, the process queue dictionary identified by xxtouch.call_callback receives this value. - out
When a call is dialed out, the process queue dictionary identified by xxtouch.call_callback receives this value. - disconnected
When an incoming or outgoing call ends, the process queue dictionary identified by xxtouch.call_callback receives this value.
Notes
When the system receives phone call in/out messages, a state is pushed into the process queue dictionary identified by this message.
Example
-- Clear message queue
proc_queue_clear("xxtouch.call_callback")
--
sys.toast("The script will now listen for call events and stop after 20 seconds")
--
-- Start listening
local eid = thread.register_event("xxtouch.call_callback", function(val)
if (val == "in") then
sys.toast("Incoming call")
elseif (val == "out") then
sys.toast("Outgoing call")
elseif (val == "disconnected") then
sys.toast("Call disconnected")
end
end)
--
sys.msleep(20000) -- wait 20 seconds
--
-- Unregister callback; without unregistering, the script will not end here
thread.unregister_event("xxtouch.call_callback", eid)
Note: Uses sys.toast
, sys.msleep
, proc_queue_clear
, thread.register_event
, thread.unregister_event