Reactor Function Reference
alert
amp
backlight
beep
contains
cron
dialog
enableAirplane
enableBluetooth
enableDate
enableWifi
fileRead
fileReadExt
fileWrite
fileWriteExt
find
getProperty
hasConnectivity
httpGet
httpPost
join
len
location
log
match
mute
near
notify
number
play
post
push
queryProvider
rand
record
round
saveProperty
sendIntent
setting
sleep
speak
split
startActivity
startIntent
startService
time
waitForConnectivity
waitForIntent
wake
Function: alert
Displays an alert dialog with text
Parameters:
name text type string default alert desc Text to display sample alert
name noisy type boolean default false desc Produce noise with the alert
Function: amp
Checks microphone maximum amplitude with the defined frequency (won't work on some LG phones)
Parameters:
name threshold type number desc Amplitude threshold, this is phone specific and the maximum is 32767 sample 1000
name frequency type number default 5000 desc Frequency to check amplitude in milliseconds, minimum is 1000
Returns:
desc Returns true if amplitude gets over the defined threshold type boolean
Function: backlight
Adjust backlight level
Parameters:
name level type number default true desc Level from range 0-100
Function: beep
Produces a beep sound
back to topFunction: contains
Check whether the provided string contains the part
Parameters:
name part type string
name string type string
Returns:
desc Returns true if part is substring of string type boolean
Function: cron
Wake-up at specified times
Parameters:
name cron expression type string default 0 0 * * * ? desc Quartz-like cron expression sample every hour - 0 0 * * * ?
Function: dialog
Display a configurable dialog for user interaction
Parameters:
name labels type array default [Question] desc Array of labels for the dialog fields sample ["First name", "Surname"]
name values type array default [] desc Array of initial values for the dialog fields sample ["Petr", "Nalevka"]
name title type string default Reactor desc Optionally forge a different title for the dialog sample Questionnaire
Returns:
desc Returns an array of fields modified by the user type array
Function: enableAirplane
Switch on/off the Airplane mode
Parameters:
name enable type boolean
Function: enableBluetooth
Switch on/off the Bluetooth
Parameters:
name enable type boolean
Function: enableDate
Switch on/off the mobile network
Parameters:
name enable type boolean
Function: enableWifi
Switch on/off the Wifi
Parameters:
name enable type boolean
Function: fileRead
Read files from device internal storage
Parameters:
name fileName type string sample myfile.txt
Function: fileReadExt
Read files in /sdcard/Reactor/fs/
Parameters:
name fileName type string sample myfile.txt
Returns:
desc Returns content of the file type string
Function: fileWrite
writes to a file into device's internal storage
Parameters:
name fileName type string default myfile.txt
name content type string
name append type boolean default false
Function: fileWriteExt
writes to a file under /sdcard/Reactor/fs/
Parameters:
name fileName type string default myfile.txt
name content type string
name append type boolean default false
06-20 01:33:06.822: INFO/ActivityManager(290): Displayed com.urbandroid.reactor/.activity.FunctionReference: +399ms
Function: find
Matches the pattern and provide first level groups
Parameters:
name pattern type string desc A Java regexp pattern sample .*([a-zA-Z]*).*
name string type string
Returns:
desc Returns an array of the matched groups type array
Function: getProperty
Retrieves value of a property, may be also a value written by a
different script
Parameters:
name propertyName type string desc Name of the property, be careful, properties are shared between scripts sample MY_SCRIPT.MY_PROPERTY
Returns:
desc Returns the property value of type either string, number or boolean type any
Function: hasConnectivity
Check whether connectivity is available
Returns:
desc Returns true if connectivity is available type boolean
Function: httpGet
HTTP request using POST method
Parameters:
name uri type string default http://www.timeanddate.com/worldclock/city.html
name param type dictionary desc Request parameters sample {"n" : "204"}
Returns:
desc Array of size 2, first item is the result code and the second is the actual retrieved content type array
Function: httpPost
HTTP request using POST method
Parameters:
name uri type string default http://www.timeanddate.com/worldclock/city.html
name param type dictionary desc Request parameters sample {"n" : "204"}
Returns:
desc Array of size 2, first item is the result code and the second is the actual retrieved content type array
Function: join
Joins an array using the delimiter
Parameters:
name array type array
name delimiter type string
Returns:
desc Returns the resulting string type string
Function: len
Length of arrays or strings
Parameters:
name object type nothing desc An array or string
Returns:
desc Returns number of elements in the provided parameter is an array, or number of characters if it is a string type ?
Function: location
Retrieve current geographic location
Parameters:
name fine type boolean default false desc Use fine accuracy if set to true
Returns:
desc Returns a dictionary with keys 'lat' and 'lon' type dictionary
Function: log
Debug logging, messages can be seen through USB debug or when running scripts
in debug mode
Parameters:
name message type string desc Text to output to the log, messages are prefixed with 'LOG'
name severe type boolean default false desc Mark log message as severe
Function: match
Matches the provided pattern against the string
Parameters:
name pattern type string desc A Java regexp pattern sample .*([a-zA-Z]*).*
name string type string
Returns:
desc Returns true if string matches the pattern type boolean
Function: mute
Mute sound alerts
Parameters:
name enable type boolean default true desc True to mute alerts
Function: near
Test if you are located in certain area
Parameters:
name lat type number desc Latitude of the target location
name lon type number desc Longitude of the target location
name dist type number default 300 desc Distance threshold to activate the function in meters
name fine type boolean default false desc Use fine accuracy if set to true
Returns:
desc Returns true if within the defined distance range type boolean
Function: notify
Status bar notification
Parameters:
name text type string desc Text of the notification
name id type number default 6 desc Notification id, use different ids if multiple notifications shall be displayed
name noisy type boolean default false desc Make sound with notification
Function: number
Converts a string to number
Parameters:
name string type string
Returns:
desc Returns a number represented by the provided string type number
Function: play
Plays a media file
Parameters:
name uri type string desc Uri of the media to play sample /mnt/sdcard/myalbum/album/song1.mp3
Returns:
desc Returns immediately, but plays the whole media file type ?
Function: post
Post a message on a connected service, services need to be connected in the
settings prior posting, service include: Twitter, Facebook...
Parameters:
name message type string desc Message to post to the connected service sample Hello there!
name service type string default all desc The service to post to, possible values: all, twitter, facebook... sample facebook
Function: push
Push an element on an array
Parameters:
name array type nothing desc The array to push on
name element type nothing desc Element to be pushed
Function: queryProvider
Query a content provider for results
Parameters:
name uri type string desc Content provider uri, check the docs for different uris sample content://com.android.contacts/contacts
name projection type string default desc Comma separated list of Columns to be retrieved sample display_name,starred
name where type string default desc The query where clause sample display_name like ? and starred = ?
name whereArgs type string default desc Comma separated arguments for the where clause sample A%,1
name order type string default desc Result ordering, either ascending ASC or descending DESC sample display_name ASC
name limit type number default 20 desc Limits the number of rows returned sample 1
Returns:
desc Returns a two dimensional matrix of the results type array
Function: rand
Generate a random number
Parameters:
name min type number desc Lower range bound
name max type number desc Upper range bound
Returns:
desc Returns an decimal number from the defined range type number
Function: record
Record and encode stream from the microphone
Parameters:
name fileName type string desc File name to store encoded stream from the microphone sample time()["ts"]
name duration type number desc Recording duration in milliseconds
Function: round
Rounds a decimal to integer
Parameters:
name round type number
Returns:
desc Returns an integer number type number
Function: saveProperty
Saves a property which may be shared by other
scripts
Parameters:
name propertyName type string desc Name of the property sample MY_SCRIPT.MY_PROPERTY
name propertyValue type nothing desc Value to be stored, may be of type string, number or boolean sample test value
Function: sendIntent
Broadcasts an intent
Parameters:
name action type string desc Intent action sample android.intent.action.VIEW
name data type string default desc Intent data sample URI to be viewed
name extra type dictionary default {} desc Intent's extra parameters dictionary sample {"time-zone" : "Europe/Prague"}
Function: setting
Access system settings
Parameters:
name key type string desc System.Setting key, for a list of available setting key please refer to android.provider.Settings.System sample screen_brightness
name value type nothing default no_value_specified desc Puts the value into the setting sample 100
Returns:
desc Returns the value of a system setting type ?
Function: sleep
Pause the execution of the script for a defined amount of time
Parameters:
name millies type number desc Time to sleep in milliseconds sample 10000
Function: speak
Uses Text to Speech to speak the defined sentence
Parameters:
name text type string desc Text to be spoken sample Hello how are you!
name lang type string default english desc Text to Speech language sample german
Function: split
Splits a string using the delimiter
Parameters:
name string type string desc String to be split
name delimiter type string default , desc Delimiter
Returns:
desc Returns the resulting array type array
Function: startActivity
Starts an activity
Parameters:
name package type string desc Application package sample com.urbandroid.sleep
name class type string default desc Class to start sample com.urbandroid.sleep.alarmclock.AlarmClock
Function: startIntent
Starts an activity with the provided intent
Parameters:
name action type string desc Intent action sample android.intent.action.VIEW
name data type string default desc Intent data sample URI to be viewed
name type type string default desc MIME type sample image/png
name extra type dictionary default {} desc Intent's extra parameters dictionary sample {"time-zone" : "Europe/Prague"}
Function: startService
Starts a service
Parameters:
name package type string desc Application package sample com.urbandroid.sleep
name class type string default desc Class to start sample com.urbandroid.sleep.alarmclock.AlarmClock
Function: time
Current time
Parameters:
name millies type number default -1 desc Optionally specify milliseconds, otherwise current time is used
Returns:
desc Returns a dictionary with various time conversions, the keys include: day, month, weekday, year, hour, minute, second, ts type dictionary
Function: waitForConnectivity
Blocks until connectivity is available
Parameters:
name timeout type number default -1 desc Give up after (milliseconds)
Returns:
desc Returns when connectivity is available type ?
Function: waitForIntent
Listen for an Intent
Parameters:
name waitAction type string desc The Intent action to listen for sample android.intent.action.BATTERY_CHANGED
name waitIgnoreFirst type boolean default false desc Ignores first occurrence of the Intent (useful for some intents which respond immediately after listening)
Returns:
desc Dictionary of Intent extra parameters e.g. for android.intent.action.BATTERY_CHANGED {"level" : "20", "temperature" : "42"} type dictionary
Function: wake
Wake-up after timeout
Parameters:
name timeout in millies type number
How to turn vibro on?
ReplyDelete