//go:generate mkdir -p classes //go:generate javac -bootclasspath $ANDROID_HOME/platforms/android-29/android.jar -classpath openpgp-api.jar -d classes PgpConnect.java //go:generate jar cf PgpConnect.jar -C classes . //go:generate rm -rf classes package main import ( "fmt" "log" "time" "gioui.org/app" ) var ( h *app.Handle connected bool pgp PGP ) func connect() { if !connected { log.Print("PlatformHandle()") h = app.PlatformHandle() log.Print("SetJVM()") SetJVM(h.JVM, h.Activity) log.Print("SetJVM() returned") RunInJVM(func(env *JNIEnv) { log.Print("NewPgpConnect()") pgp = NewPgpConnect(env, h.Activity) }) connected = true } } func checkPermission() bool { connect() //return pgp.CheckPermission(env) return false } func callJni() { connect() labchan <- fmt.Sprintf("JVM = %d", h.JVM) labchan <- fmt.Sprintf("Activity = %d", h.Activity) time.Sleep(time.Second / 5) val := pgp.Encrypt("greg_pomerantz@yahoo.com", "hi there") //val := pgp.Encrypt("root@example.com", "hi there") log.Print("val = ", val) val2 := pgp.Decrypt(val) labchan <- "result = " + val2 }