forked from xlab/android-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (37 loc) · 876 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"log"
"runtime"
"github.com/xlab/android-go/app"
)
func init() {
app.SetLogTag("GolangExample")
}
func main() {
log.Println("NativeActivity has started ^_^")
log.Printf("Platform: %s %s", runtime.GOOS, runtime.GOARCH)
nativeWindowEvents := make(chan app.NativeWindowEvent)
app.Main(func(a app.NativeActivity) {
a.HandleNativeWindowEvents(nativeWindowEvents)
a.InitDone()
for {
select {
case event := <-a.LifecycleEvents():
switch event.Kind {
case app.OnCreate:
log.Println(event.Kind, "handled")
default:
log.Println(event.Kind, "event ignored")
}
case event := <-nativeWindowEvents:
switch event.Kind {
case app.NativeWindowRedrawNeeded:
a.NativeWindowRedrawDone()
log.Println(event.Kind, "handled")
default:
log.Println(event.Kind, "event ignored")
}
}
}
})
}