Table of Contents

HopDroid

This documents the HopDroid JavaScript module that enables applications to access Android on-device features. Of course, this module is only useful for Hop Android installation, that is, Hop running on an Android divece.

Use require( hop.hopdroid ) to use it as a library.

Constructor

new hopdroid.phone()

Creates a custom phone object. This object is required to access device features and to install event listeners.

A phone object posses the following attributes:

Methods

phone.addEventListener( event, listener )

Installs an event listener for the phone. All events have an associated value whose components are stored in an array. The known events are:

phone.sendSms( number, text )

Sends an sms to phone number. Example:

const hopdroid = require( hop.hopdroid );
const phone = new hopdroid.phone();
const phoneNumber = ...;

phone.sendSms( phoneNumber, "Sent from Hop.js" );

phone.placeCall( number )

Place a call to number.

phone.stopCall( number )

Stop the current call.

phone.vibrate( frequency = 2, repetition = 1 )

Vibrate the phone. The argument frequency can either be:

If repetition is a positive integer, it tells how many times to repeat the vibration. Example:

const hopdroid = require( hop.hopdroid );
const phone = new hopdroid.phone();

const dot = 200;
const dash = 500;
cont shortGap = 200;
const mediumGap = 500;
const longGap = 1000;

const sos = [ 0, 
              // S
              dot, shortGap, dot, shortGap, dot,
              // O
              dash, shortGap, dash, shortGap, dash,
              // S
              dot, shortGap, dot, shortGap, dot,
              longGap ];
                          
phone.vibrate( sos );