android

package
v1.17.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: BSD-3-Clause Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package android is the platform backend for Android (GOOS=android, SPEC §24): the JNI entry points the Java embedding calls, the thread that runs the program's main, the log lines sent to logcat, and, from step 25.3, the looper, the surface, the input and the services.

It is the only package with cgo (D21), and only in the *_android.go files; the files without that suffix are plain Go that builds and is tested everywhere (SPEC §24.13). No C type, C pointer or JNI reference leaves the package.

Flutter: shell/platform/android (the embedding of the engine)

Index

Constants

View Source
const A11yEnv = "GLUTTER_A11Y"

A11yEnv is the environment variable (an intent extra) that forces the accessibility bridge on in debug builds, so that the emulator images without TalkBack can test it (SPEC §24.13). It is read only in debug builds (foundation.DebugMode).

Flutter: no counterpart

View Source
const DevEventsEnv = "GLUTTER_DEV_EVENTS"

DevEventsEnv is the environment variable (an intent extra) with the script of synthetic events that debug builds replay after the first frame, so that a proof screenshot or a device test can show an app after a tap or a swipe where `adb shell input` cannot reach (SPEC §24.13). It is read only in debug builds (foundation.DebugMode).

Flutter: no counterpart

Variables

This section is empty.

Functions

func IsPadKey

func IsPadKey(keyCode int) bool

IsPadKey says whether a key of a gamepad device is one that the pad service takes: a button of the pad or its D-pad. Back and the other keys that a pad sends are left to the keyboard. The Java side asks the same of its own table (GamepadInput.isPadKey).

Flutter: no counterpart

func PointerIconType

func PointerIconType(c platform.MouseCursor) int

PointerIconType returns the android.view.PointerIcon type of a cursor: the arrow for the unspecified cursor and for any cursor that Flutter's table does not know.

Flutter: shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java MouseCursorPlugin.resolveSystemCursor

Types

type DevEvent

type DevEvent struct {
	// Kind is "wait", "tap", "swipe", "key", "text", "compose", "action", "back", "a11y" or "relmove".
	Kind string
	// Wait is how long to wait, for "wait"; and a swipe takes its Millis.
	Wait time.Duration
	// X1, Y1 and X2, Y2 are the points of a "tap" (the first) and a "swipe", in pixels of the view; the
	// motion of a "relmove" is X1, Y1.
	X1, Y1, X2, Y2 float64
	// Millis is how long a swipe takes.
	Millis int
	// Key is the name of a key: KEYCODE_ENTER; for "text", the text to type; for "compose", the
	// pieces that the input method composes one after the other, separated by commas.
	Key string
	// Label is, for "a11y", the text that the node has: Key is the action.
	Label string
}

DevEvent is one step of a dev events script.

Flutter: no counterpart

func ParseDevEvents

func ParseDevEvents(script string) ([]DevEvent, error)

ParseDevEvents reads a dev events script: steps separated by ";", each "name:arguments".

wait:500ms          waits
tap:x,y             a touch down and up at the position
swipe:x1,y1,x2,y2,ms  a finger from the first point to the second in that many milliseconds
key:KEYCODE_ENTER   a key down and up
text:hello          the input method commits the text into the text field that has the focus
compose:a,b,c       the input method composes a, then b, then c, and ends with c committed
action:enter        the input method does the action of its Enter key (the field's action)
back:pop            the system's back; back:gesture a predictive back gesture that is completed,
                    back:cancel one that is cancelled
relmove:dx,dy       a motion of the mouse while the pointer is captured (the pointer lock): the
                    view gets it as a captured pointer event (SOURCE_MOUSE_RELATIVE)
a11y:click,Add      the accessibility action on the first node whose text, content description or
                    hint contains the label, as a screen reader performs it: click, longclick,
                    scrollforward, scrollbackward, focus, a11yfocus, a11yclear, dismiss, copy, cut,
                    paste, expand or collapse (the label is the rest of the step, commas included)

A step that is not one of these, or has the wrong arguments, fails with AndroidDevEventsInvalid.

Flutter: no counterpart

type Platform

type Platform struct {
	// contains filtered or unexported fields
}

Platform is the platform.Platform of Android: one window that fills the activity's view, drawn by the UI thread, which owns the framework and the renderer (SPEC §24.3). It is plain Go over a host (the looper and the choreographer, host_android.go) and a bridge (the calls of the Java side), so that the tests run it with fakes.

Flutter: shell/platform/android/platform_view_android.cc PlatformViewAndroid

func (*Platform) Clipboard

func (p *Platform) Clipboard() platform.Clipboard

Clipboard returns the clipboard of Android.

Flutter: services/clipboard.dart Clipboard

func (*Platform) Close

func (p *Platform) Close() error

Close releases the platform. The host belongs to the process, so there is nothing to release.

Flutter: no counterpart

func (*Platform) Desktop

func (p *Platform) Desktop() mobile.Services

Desktop returns the desktop services of Android: opening a URI and notifications (SPEC §24.11). It may be called from any goroutine.

Flutter: no counterpart (the url_launcher and flutter_local_notifications plugins)

func (*Platform) Displays

func (p *Platform) Displays() []platform.Display

Displays lists the one display, with the density and the refresh rate Android reports.

Flutter: shell/platform/android/android_display.cc AndroidDisplay

func (*Platform) NewWindow

func (p *Platform) NewWindow(cfg platform.WindowConfig) (platform.Window, error)

NewWindow returns the one window of the activity. A second window, a dialog, a borderless window or a window with a parent fails with WindowUnsupported (SPEC §24.2).

Flutter: shell/platform/android/io/flutter/embedding/android/FlutterView.java FlutterView

func (*Platform) Post

func (p *Platform) Post(fn func())

Post runs fn on the UI thread, in order with the events of the Java side. It is safe to call from any goroutine.

Flutter: shell/common/shell.cc Shell::GetTaskRunners (PostTask)

func (*Platform) Run

func (p *Platform) Run(ctx context.Context, h platform.Handler) error

Run owns the UI thread's loop: it runs the events of the Java side and the functions that Post queued, in order, and asks the choreographer for a frame while one is wanted and can be drawn. It returns nil when ctx is cancelled. A second call while Run is active fails with PlatformAlreadyRunning.

Flutter: shell/platform/android/android_shell_holder.cc AndroidShellHolder (the UI task runner)

func (*Platform) Services

func (p *Platform) Services() platform.Services

Services returns the services of Android: the accessibility bridge (step 25.11, accessibility.go). The desktop services of step 25.12 are not part of it.

Flutter: no counterpart

func (*Platform) Settings

func (p *Platform) Settings() platform.Settings

Settings returns the system's settings that the Java side reported (SPEC §24.7); until it does, the defaults: light, the text scale 1 and the locale en-US.

Flutter: shell/platform/android/io/flutter/embedding/engine/systemchannels/SettingsChannel.java SettingsChannel

Directories

Path Synopsis
Package aaudio is the AAudio backend of the audio service on Android (SPEC §28.3, step 31.6): playback and capture of float32 frames through libaaudio.so (Android 8, API 26), called through purego, with a data callback that is made once, the low-latency performance mode, a stream that is made again when the device it was on is disconnected, and a device that pauses while the app is hidden.
Package aaudio is the AAudio backend of the audio service on Android (SPEC §28.3, step 31.6): playback and capture of float32 frames through libaaudio.so (Android 8, API 26), called through purego, with a data callback that is made once, the low-latency performance mode, a stream that is made again when the device it was on is disconnected, and a device that pauses while the app is hidden.
Package asensor is the motion sensors backend of Android (SPEC §28.4, step 31.7): the accelerometer and the gyroscope through the sensor manager of the NDK (libandroid.so, Android 8, API 26), called through purego, with the events of every open sensor read on a looper that lives on an OS thread of its own.
Package asensor is the motion sensors backend of Android (SPEC §28.4, step 31.7): the accelerometer and the gyroscope through the sensor manager of the NDK (libandroid.so, Android 8, API 26), called through purego, with the events of every open sensor read on a looper that lives on an OS thread of its own.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL