AndroidApplication class
Main entry point and handler for Android applications.
Specializes Application for the Android platform, wiring the engine to the android_native_app_glue lifecycle and dispatching the platform commands it receives.
Base classes
- class Application
- Base class for the main entry point of an nCine application.
Public static functions
- static void Run(struct android_app* state, CreateAppEventHandlerDelegate createAppEventHandler)
- Entry point method to be called in the
android_main()function. -
static void ProcessCommand(struct android_app* state,
std::
int32_t cmd) - Processes an Android application lifecycle command.
Public functions
- auto IsInitialized() const -> bool
- Returns
trueif the application has already called Init(). - auto IsScreenRound() const -> bool
- Returns
trueif the main screen is round. - auto OpenUrl(StringView url) -> bool override
- Opens the specified URL in a default web browser.
- void HandleBackInvoked()
- Handles invocation of the system Back gesture.
- void HandleIntent(StringView action, StringView uri)
- Handles the intent sent to the application activity.
- void HandleContentBoundsChanged(Recti bounds)
- Handles changes of content bounds.
- void HandleTextInput(char32_t codePoint)
- Handles a Unicode character entered on the screen keyboard.
-
void HandleKeyEvent(bool pressed,
std::
int32_t keyCode) - Handles a key event generated by the screen keyboard.
- auto CanShowScreenKeyboard() -> bool override
- Returns
trueif screen (software) keyboard is supported and ShowScreenKeyboard() should succeed. - auto IsScreenKeyboardVisible() -> bool override
- Returns
trueif the screen (software) keyboard is currently shown, alwaysfalseif it cannot be queried. - auto ToggleScreenKeyboard() -> bool override
- Toggles the screen (software) keyboard.
-
auto ShowScreenKeyboard(Containers::
StringView initialText = {}, Containers:: Function<void(Containers:: StringView)>&& onCompleted = {}) -> bool override - Shows the screen (software) keyboard.
- auto HideScreenKeyboard() -> bool override
- Hides the screen (software) keyboard.
-
void Vibrate(std::
int32_t milliseconds) override - Vibrates the device for the specified duration in milliseconds; no-op if not supported.
- void ShowStatusBar() override
- Shows the system status bar (if supported).
- void HideStatusBar() override
- Hides the system status bar (if supported).
Friends
- auto theApplication() -> Application&
- Returns the application instance.
Function documentation
static void nCine:: AndroidApplication:: Run(struct android_app* state,
CreateAppEventHandlerDelegate createAppEventHandler)
Entry point method to be called in the android_main() function.
| Parameters | |
|---|---|
| state | Native application state provided by the glue layer |
| createAppEventHandler | Factory delegate that creates the application's event handler |
static void nCine:: AndroidApplication:: ProcessCommand(struct android_app* state,
std:: int32_t cmd)
Processes an Android application lifecycle command.
| Parameters | |
|---|---|
| state | Native application state provided by the glue layer |
| cmd | One of the APP_CMD_* commands dispatched by the glue layer |
void nCine:: AndroidApplication:: HandleIntent(StringView action,
StringView uri)
Handles the intent sent to the application activity.
| Parameters | |
|---|---|
| action | Intent action string |
| uri | Intent data URI |
void nCine:: AndroidApplication:: HandleContentBoundsChanged(Recti bounds)
Handles changes of content bounds.
| Parameters | |
|---|---|
| bounds | New content bounds, accounting for insets such as display cutouts |
void nCine:: AndroidApplication:: HandleTextInput(char32_t codePoint)
Handles a Unicode character entered on the screen keyboard.
| Parameters | |
|---|---|
| codePoint | Entered Unicode code point |
Can be called from the Java UI thread, the event is queued and dispatched on the main thread.
void nCine:: AndroidApplication:: HandleKeyEvent(bool pressed,
std:: int32_t keyCode)
Handles a key event generated by the screen keyboard.
| Parameters | |
|---|---|
| pressed | true if the key was pressed, false if it was released |
| keyCode | Android key code of the key |
Can be called from the Java UI thread, the event is queued and dispatched on the main thread.
bool nCine:: AndroidApplication:: ShowScreenKeyboard(Containers:: StringView initialText = {},
Containers:: Function<void(Containers:: StringView)>&& onCompleted = {}) override
Shows the screen (software) keyboard.
Two kinds of platform answer this, and a caller that wants to work on both has to serve both. Where the keyboard is an overlay that feeds keystrokes (Windows, Android) it types into whatever has focus and the text arrives as IInputEventHandler::initialText and onCompleted are unused there. Where it is a modal editor that collects a whole string (the PS Vita's IME) there are no keystrokes to deliver: initialText seeds the editor with what the field already holds, and onCompleted is invoked once with the finished string, which REPLACES that field rather than appending to it. It is not invoked at all if the user cancels.
So pass both, keep handling OnTextInput, and the field ends up right either way.
Application& theApplication()
Returns the application instance.
Returns the singleton application instance.