mobile/example/libhello
Hyang-Ah Hana Kim e3048a987d example/libhello: update main.go to initiate java.Init.
changes required after golang.org/cl/5555

Change-Id: If355dcfa0edfdc204eac4e89837927ab9a978b65
Reviewed-on: https://go-review.googlesource.com/5651
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-02-23 21:57:36 +00:00
..
hi all: update docs to remove code.google.com 2014-12-11 14:15:30 +00:00
src go.mobile/example/libhello: make example self-contained 2014-09-12 10:54:02 -04:00
AndroidManifest.xml go.mobile/example/libhello: make example self-contained 2014-09-12 10:54:02 -04:00
README all: update docs to remove code.google.com 2014-12-11 14:15:30 +00:00
all.bash go.mobile/example/libhello: fix typo. 2014-11-05 14:00:48 -05:00
all.bat example: add windows batch files 2014-12-22 13:10:26 +00:00
build.xml go.mobile/example/libhello: make example self-contained 2014-09-12 10:54:02 -04:00
main.go example/libhello: update main.go to initiate java.Init. 2015-02-23 21:57:36 +00:00
make.bash all: update docs to remove code.google.com 2014-12-11 14:15:30 +00:00
make.bat example: add windows batch files 2014-12-22 13:10:26 +00:00

README

The libhello app demonstrates calling Go code from a primarily Java app.

Starting in Java lets you program against Android's extensive UI
libraries in their native language and call into Go for library code
(business logic, code shared with a Go server, portable code).

The Java entry point to the program is the file
src/com/example/hello/MainActivity.java, where the statement

	Hi.Hello("world");

is a call into Go code.

The Go code is in a package called hi, the file is hi/hi.go, and it
contains the function Hello:

	func Hello(name string) {
		fmt.Printf("Hello, %s!\n", name)
	}

Java language bindings are generated for this package using the gobind
tool. There is a user guide for gobind at 

	http://golang.org/x/mobile/cmd/gobind

The generated source has been included in the distribution. If you
modify the exported interface of package hi, you have to run gobind
manually before calling all.bash.

Along with the gobind generated source, the app includes a main.go file
to define the app entry point.

make.bash builds the app, all.bash deploys it.

The first step in building the app is to build the native shared
library out of the Go code, and place it in
libs/armeabi-v7a/libgojni.so.

The second step is building the app with the standard Android build
system by calling ant debug (also done in make.bash). Two extra Java
files are included in the build by make.bash to support the language
bindings. This produces an apk ready for running on a device.