1. ww
  2. godroid



package godroid
import "bitbucket.org/ww/godroid"

Go bindings for the SL4A Android API proxy.
Written by William Waites in 2011.

This software is distributed under the GNU GPL version 3
or above.

Usage example,

    droid, err := NewDroid("")
    if err != nil {

    _, err = droid.Call("makeToast", "hello world")
    if err != nil {

To build for Android, make sure the cross compiler is installed
and built for ARM, then simply do,

    GOOS=linux GOARCH=arm GOARM=5 goinstall -u -v bitbucket.org/ww/godroid


type Droid struct {
    // contains unexported fields

func NewDroid(addr string) (droid *Droid, err os.Error)
Create a new connection to the SL4A proxy running on the
given TCP port. This is for insecure API bridges.

func StartDroid() (droid *Droid, err os.Error)
Create a new connection to the SL4A proxy mentioned in
the environment variables.

func (droid *Droid) Call(method string, params ...interface{}) (result interface{}, err os.Error)
Call a proxied API function. The method is required and the
parameters get serialised to JSON and should be whatever
the API function requires. The result likewise gets
deserialised from the JSON response given by the server.