The PhoneState component is able to detect phone state changes.
pst = app.CreatePhoneState(
types )
→
app object: PhoneState
The callback data depends on the type:
“CellLocation” : object: {
cellId,
areaCode }
“DataConnection” : object: {
state,
networkType }
“DataActivity” : unknown
“CallState” : object: {
state,
number }
“ServiceState” : string: “OutOfService”
“SignalStrength” : number: float
“CallForwarding” : boolean
“MessageWaiting” : boolean
Example - Demo
function OnStart()
{
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
txt = app.CreateText( "", 0.95, 0.95, "multiline,left" );
txt.SetTextSize( 14 );
lay.AddChild( txt );
app.AddLayout( lay );
var types = "CellLocation,DataConnection,DataActivity,CallState,"
+ "ServiceState,SignalStrength,CallForwarding,MessageWaiting";
state = app.CreatePhoneState( types );
state.SetOnChange( state_OnChange );
state.Start();
}
var log = [];
function state_OnChange( type, data )
{
log.push( type.bold() + ":<br>\t" + JSON.stringify(data) );
txt.SetHtml( log.join("<br>") );
}
Methods
The following methods are available on the PhoneState object:
Number: integer
String: number
String: “CellLocation”, “DataConnection”, “DataActivity”, “CallState”, “ServiceState”, “SignalStrength”, “CallForwarding”, “MessageWaiting”
String: “Connected” or “Disconnected”
String: “Unknown”
String: “Idle”
pst.Batch
Batch method calls to be able to set all object's properties at once.
Note that you need to specify each parameter (use “” or null to leave some out)
Inherited methods can be called by appending an underscore to the function name (ie. txt.Batch({ SetBackColor_: [“red”] })
pst.GetType
Returns the control class name.
pst.SetOnChange
Define a callback function which is called when a phone state has changed.
pst.Start
Start listening.
pst.Stop
Stop listening.