打包方式:
fyne package -os android -appID com.example.myapp -icon Icon.png
安装:
fyne install -os android --id com.example.myapp
对于用户生成的数据可以使用:perferences来保存。
保存位置:
linux: ~/.config/fyne/${app-id}
android:
方式:
package main
import (
"fmt"
"time"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.NewWithID("com.example.tutorial.preferences")
w := a.NewWindow("Timeout")
str := binding.NewString()
fmt.Println(a.Storage().RootURI())
// fmt.Println("perferences:", a.Storage().RootURI())
var timeout time.Duration
timeoutSelector := widget.NewSelect([]string{"10 seconds", "30 seconds", "1 minute"}, func(selected string) {
switch selected {
case "10 seconds":
timeout = 10 * time.Second
case "30 seconds":
timeout = 30 * time.Second
case "1 minute":
timeout = time.Minute
}
a.Preferences().SetString("AppTimeout", selected)
})
timeoutSelector.SetSelected(a.Preferences().StringWithFallback("AppTimeout", "10 seconds"))
go func() {
time.Sleep(timeout)
a.Quit()
}()
w.SetContent(container.NewVBox(
timeoutSelector,
widget.NewEntryWithData(str),
))
w.ShowAndRun()
}