github.com/pojntfx/hydrapp/hydrapp@v0.0.0-20240516002902-d08759d6ca9f/pkg/generators/android_vanillajs_forms.go.tpl (about) 1 //go:build android 2 // +build android 3 4 package main 5 6 /* 7 #include "hydrapp_android.h" 8 */ 9 import "C" 10 import ( 11 "context" 12 "log" 13 14 _ "github.com/pojntfx/hydrapp/hydrapp/pkg/fixes" 15 "github.com/pojntfx/hydrapp/hydrapp/pkg/utils" 16 17 frontend "{{ .GoMod }}/pkg/frontend" 18 ) 19 20 //export Java_{{ .JNIExport }}_MainActivity_LaunchBackend 21 func Java_{{ .JNIExport }}_MainActivity_LaunchBackend(env *C.JNIEnv, activity C.jobject, filesDir C.jstring) C.jstring { 22 if err := utils.PolyfillEnvironment(C.GoString(C.get_c_string(env, filesDir))); err != nil { 23 log.Fatalln("could not polyfill environment:", err) 24 } 25 26 frontendURL, _, err := frontend.StartServer(context.Background(), "", false) 27 if err != nil { 28 log.Fatalln("could not start frontend:", err) 29 } 30 31 log.Println("Frontend URL:", frontendURL) 32 33 return C.get_java_string(env, C.CString(frontendURL)) 34 } 35 36 func main() {}