Update android.go

This commit is contained in:
MatejMagat305 2024-03-24 18:12:14 +01:00 committed by GitHub
parent c617a99f3a
commit cbf25fe14d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,6 +62,10 @@ static void unlockJNI(uintptr_t vmp) {
const char * getInternalStoragePathMy(){
return GetANativeActivity()->internalDataPath;
}
const char * getExternalStoragePathMy(){
return GetANativeActivity()->externalDataPath;
}
*/
import "C"
import (
@ -73,6 +77,7 @@ import (
func doSpecific() {
fmt.Println("calling GetANativeActivity()->internalDataPath: ", C.GoString(C.getInternalStoragePathMy())) // this is only example to show how work GetANativeActivity()
fmt.Println("calling GetANativeActivity()->externalDataPath: ", C.GoString(C.getExternalStoragePathMy()))
// fmt.Println("calling rl.HomeDir(): ", rl.HomeDir()) // this work too
err := RunOnJVM(func(vm, env, ctx uintptr) error {
// do anything with jni
@ -83,7 +88,7 @@ func doSpecific() {
}
}
func RunOnJVM(fn func(vm, env, ctx uintptr) error) error {
func RunOnJVM(fn func(vm, env, ctx uintptr) error) error { // this is show how get to C pointer to JNIEnv*,JavaVM* and class of activity
if fn == nil {
return errors.New("fn is nil")
}