Start with the Template sample and copy it to a new location, with a name change to reflect it's capabilities. Follow the instructions in the Template readme to adapt it to your needs.
-
- test() - returns a string from native.
- testInput(string) - supplies input and returns it as part of another string.
- templateProperty - numeric property that can be set and retrieved.
- testAsync(callback) - asynchronous call that fires the callback when complete.
- testAsyncJSON(callback) - asynchronous call that fires a callback which receives a JSON object.
- testAsyncJSONio(json, callback) - asynchronous call that takes JSON data and sends a modified JSON object on the callback.
- startThread(callback) - starts a thread that fires events to a callback.
- stopThread(callback) - ends the thread that is firing the callback.
-
- setPreventSleep(boolean) - true prevents the screen from sleeping, false allows it to.
- isSleepPrevented - true if sleep is prevented, false otherwise.
-
- var id = community.led.startLed("FFFF00", "10") - start the LED blinking with the given colour, for the number of times requested. 0 is indefinite.
- community.led.stopLed(id) - stop the LED blink request with the given id.
-
- createThumbNail(path, {width: width, height: height, quality:quality}) - Create a thumbnail of the image at "path" with the given options.
-
- unzipPackage("shared/documents/bbtest.zip", "shared/documents/") - unzip the given file to the directory given.
-
- vibration_request({ "duration" : [int: duration], "intensity" : [int: intensity]}, [function: callback]) - vibrate phone with given intensity and duration, with optional callback.
-
- startRead(codeFound, errorFound, "myCanvas", onStartRead) - Scan for barcodes and paint viewfinder on myCanvas
- stopRead(onStopRead, errorFound) - stop the reading process
-
- var result = community.screendisplay.sdgetsize();
Result is a javascript object with the following properties
pixelWidth, // Pixel Size - width pixelHeight, // Pixel Size - height physicalWidth, // Physical Size mm - width physicalHeight, // Physical Size mm - height ppmm, // Pixels Per mm ppmmX, // Pixels Per mm - X ppmmY, // Pixels Per mm - Y ppi, // Pixels Per Inch ppiX, // Pixels Per Inch - X ppiY, // Pixels Per Inch - Y pixelShape; // Physical Shape
-
- getModelNumber() - returns model number such as 'Z10', 'Q10', 'Q5'
- getRoamingStatus() - return Roaming Status of the device as 'true' or 'false'
- getMCC() - returns Mobile Country Code
- getMNC() - returns Mobile Network Code, that identifies the carrier
- getNetwork() - returns a JSON object with information about the current default connection.
- hasPhysicalKeyboard() - returns 1 if device has a hardware keyboard, or 0 otherwise.
-
- hash( params ) - Hash using any SHA or AES CBC algorithm
- generateKey( params ) - generate a key using AES CBC
- encrypt( params ) - encrypt the input using AES CBC
- decrypt( params ) - decrypt using AES CBC
- random( size: int ) - return a random data string of the given length
-
- community.clipboard.getText() - Get text from clipboard.
- community.clipboard.setText( string ); - Set string to clipboard.