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 ¶
- func Available() bool
- func CallBool(class, method, sig string, args ...any) (bool, error)
- func CallBytes(class, method, sig string, args ...any) ([]byte, error)
- func CallInt(class, method, sig string, args ...any) (int, error)
- func CallString(class, method, sig string, args ...any) (string, error)
- func CallVoid(class, method, sig string, args ...any) error
- func GoBytes(env unsafe.Pointer, b uintptr) []byte
- func GoString(env unsafe.Pointer, s uintptr) string
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 CallString ¶
CallString calls a static method returning a String; null is "".
Types ¶
This section is empty.