com.google.ase
Class AndroidProxy

java.lang.Object
  extended by com.google.ase.AndroidProxy

public class AndroidProxy
extends java.lang.Object

A proxy for JSON RPC calls to access an AndroidFacade. Each RPC method expects a JSONArray of parameters and returns a JSONObject as a result. The JavaDoc below describes the params in terms of what is expected from JSON RPC clients.

Author:
Damon Kohler (damonkohler@gmail.com)

Constructor Summary
AndroidProxy(AndroidFacade facade)
           
 
Method Summary
 JSONObject exit(JSONArray params)
           
 JSONObject exitWithResultCanceled(JSONArray params)
           
 JSONObject exitWithResultOk(JSONArray params)
           
 JSONObject geocode(JSONArray params)
           
 JSONObject getExtra(JSONArray params)
           
 JSONObject getInput(JSONArray params)
           
 JSONObject getLastKnownLocation(JSONArray params)
           
 JSONObject getRingerVolume(JSONArray params)
           
 JSONObject makeToast(JSONArray params)
           
 JSONObject notify(JSONArray params)
           
 void onActivityResult(int requestCode, int resultCode, Intent data)
          This must be called in the Context's onActivityResult.
 void onDestroy()
          This must be called in the Context's onDestroy.
 JSONObject putResultExtra(JSONArray params)
           
 JSONObject readLocation(JSONArray params)
           
 JSONObject readPhoneState()
           
 JSONObject readSensors(JSONArray params)
           
 JSONObject receiveEvent(JSONArray params)
           
 JSONObject sendTextMessage(JSONArray params)
           
 JSONObject setRingerSilent(JSONArray params)
           
 JSONObject setRingerVolume(JSONArray params)
           
 JSONObject setWifiEnabled(JSONArray params)
           
 JSONObject speak(JSONArray params)
           
 JSONObject startActivity(JSONArray params)
           
 JSONObject startActivityForResult(JSONArray params)
           
 JSONObject startLocating(JSONArray params)
           
 JSONObject startSensing(JSONArray params)
           
 JSONObject startTrackingPhoneState()
           
 JSONObject stopLocating(JSONArray params)
           
 JSONObject stopSensing(JSONArray params)
           
 JSONObject stopTrackingPhoneState()
           
 JSONObject vibrate(JSONArray params)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AndroidProxy

public AndroidProxy(AndroidFacade facade)
Method Detail

speak

@Rpc(description="Speaks the provided message using TTS.",
     params="String message")
public JSONObject speak(JSONArray params)

startTrackingPhoneState

@Rpc(description="Starts tracking phone state.")
public JSONObject startTrackingPhoneState()

readPhoneState

@Rpc(description="Returns the current phone state.",
     returns="A map of \"state\" and \"incomingNumber\"")
public JSONObject readPhoneState()

stopTrackingPhoneState

@Rpc(description="Stops tracking phone state.")
public JSONObject stopTrackingPhoneState()

setRingerSilent

@Rpc(description="Sets whether or not the ringer should be silent.",
     params="Boolean silent")
public JSONObject setRingerSilent(JSONArray params)

getRingerVolume

@Rpc(description="Returns the current ringer volume.",
     returns="The current volume as an Integer.")
public JSONObject getRingerVolume(JSONArray params)

setRingerVolume

@Rpc(description="Sets the ringer volume.",
     params="Integer volume")
public JSONObject setRingerVolume(JSONArray params)

startSensing

@Rpc(description="Starts recording sensor data to be available for polling.")
public JSONObject startSensing(JSONArray params)

readSensors

@Rpc(description="Returns the current value of all collected sensor data.")
public JSONObject readSensors(JSONArray params)

stopSensing

@Rpc(description="Stops collecting sensor data.")
public JSONObject stopSensing(JSONArray params)

startLocating

@Rpc(description="Starts collecting location data.",
     params="String accuracy (\"fine\", \"coarse\")")
public JSONObject startLocating(JSONArray params)

readLocation

@Rpc(description="Returns the current location.",
     returns="A map of location information.")
public JSONObject readLocation(JSONArray params)

stopLocating

@Rpc(description="Stops collecting location data.")
public JSONObject stopLocating(JSONArray params)

getLastKnownLocation

@Rpc(description="Returns the last known location of the device.",
     returns="A map of location information.")
public JSONObject getLastKnownLocation(JSONArray params)

geocode

@Rpc(description="Returns a list of addresses for the given latitude and longitude.",
     params="Double latitude, Double longitude, [Int maxResults]",
     returns="A list of addresses.")
public JSONObject geocode(JSONArray params)

sendTextMessage

@Rpc(description="Sends a text message.",
     params="String subject, String body")
public JSONObject sendTextMessage(JSONArray params)

setWifiEnabled

@Rpc(description="Enables or disables Wifi according to the supplied boolean.",
     params="Boolean enabled")
public JSONObject setWifiEnabled(JSONArray params)

startActivityForResult

@Rpc(description="Starts an activity for result and returns the result.",
     params="String action, [String uri]",
     returns="A map of result values.")
public JSONObject startActivityForResult(JSONArray params)

startActivity

@Rpc(description="Starts an activity.",
     params="String action, String uri")
public JSONObject startActivity(JSONArray params)

makeToast

@Rpc(description="Displays a short-duration Toast notification.",
     params="String message")
public JSONObject makeToast(JSONArray params)

getInput

@Rpc(description="Displays an input {@link AlertDialog} and returns the input string.",
     params="String title, String message",
     returns="The input string.")
public JSONObject getInput(JSONArray params)

vibrate

@Rpc(description="Vibrates the phone for a specified duration in milliseconds.",
     params="[Integer milliseconds]")
public JSONObject vibrate(JSONArray params)

notify

@Rpc(description="Displays a notification that will be canceled when the user clicks on it.",
     params="String message, [String title], [String ticker]")
public JSONObject notify(JSONArray params)

putResultExtra

@Rpc(description="Add an extra value to the result of this script.",
     params="String name, String/Integer/Double/Boolean value")
public JSONObject putResultExtra(JSONArray params)

getExtra

@Rpc(description="Returns an extra value that was specified in the launch intent.",
     params="String name, [Integer/Double/Boolean default]",
     returns="The extra value.")
public JSONObject getExtra(JSONArray params)

exit

@Rpc(description="Exits the activity or service running the script.")
public JSONObject exit(JSONArray params)

exitWithResultOk

@Rpc(description="Exits the activity or service running the script with RESULT_OK.")
public JSONObject exitWithResultOk(JSONArray params)

exitWithResultCanceled

@Rpc(description="Exits the activity or service running the script with RESULT_CANCELED.")
public JSONObject exitWithResultCanceled(JSONArray params)

receiveEvent

@Rpc(description="Receives the most recent event (i.e. location or sensor update, etc.",
     returns="Map of event properties.")
public JSONObject receiveEvent(JSONArray params)

onActivityResult

public void onActivityResult(int requestCode,
                             int resultCode,
                             Intent data)
This must be called in the Context's onActivityResult.


onDestroy

public void onDestroy()
This must be called in the Context's onDestroy.