android

package
v1.0.31-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package android calls Java from Go on Android: static methods of the app's own classes (from a jar in one of its packages, which giode build adds to the APK) and of the Android SDK, through the app's class loader.

ok, err := android.CallBool("com/example/usb/Usb", "hasPermission",
	"(Landroid/content/Context;Ljava/lang/String;)Z", android.Context(), name)

Signatures are JNI type descriptors. Java runs a function with the JNI environment for anything the Call helpers don't cover (instance methods, fields, arrays), using git.wow.st/gmp/jni.

Java calling Go goes through //export Java_<class>_<method> functions in the app; GoString and GoBytes convert their arguments.

On other platforms the Call helpers return errors.ErrUnsupported and Available reports false.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available() bool

Available reports whether Java can be called: true on Android.

func CallBool

func CallBool(class, method, sig string, args ...any) (bool, error)

CallBool calls a static method returning a boolean.

func CallBytes

func CallBytes(class, method, sig string, args ...any) ([]byte, error)

CallBytes calls a static method returning a byte[]; null is nil.

func CallInt

func CallInt(class, method, sig string, args ...any) (int, error)

CallInt calls a static method returning an int.

func CallString

func CallString(class, method, sig string, args ...any) (string, error)

CallString calls a static method returning a String; null is "".

func CallVoid

func CallVoid(class, method, sig string, args ...any) error

CallVoid calls a static void method.

func GoBytes

func GoBytes(env unsafe.Pointer, b uintptr) []byte

GoBytes converts a Java byte[] passed to a native method; null is nil.

func GoString

func GoString(env unsafe.Pointer, s uintptr) string

GoString converts a Java string passed to a native method; null is "".

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL