android-activity
Glue for building Rust applications on Android with NativeActivity or GameActivity
0.6.1
24M downloads/mo
#1902 most downloaded on crates.io
rust-mobile/android-activity
What this package is like to depend on
Last release 5 months ago
24 Mar 2026
Ships unpredictably
gaps range from 2 weeks to 1.9 years
Nearly every release is documented
notes for 13 of 13 stable releases
Nothing withdrawn
no release was ever pulled
4 years old
17 releases · first in 2022
1 release in the last 12 months
see the full history below
Release timeline
17 releases · Jul 2022 to Mar 2026Releases
latest 17-
0.6.124 Mar 2026Release notes
Open source →Added
- input:
TextInputActionenum representing action button types on soft keyboards. (#216) - input:
InputEvent::TextActionevent for handling action button presses from soft keyboards. (#216) - The
ndkandndk-syscrates are now re-exported underandroid_activity::ndkandandroid_activity::ndk_sys(#194) AndroidApp::java_main_looper()gives access to theALooperfor the Java main / UI thread (#198)AndroidApp::run_on_java_main_thread()can be used to run boxed closures on the Java main / UI thread (#232)- Support for an optional
android_on_createentry point that gets called from theActivity.onCreate()callback beforeandroid_main()is called, allowing for doing some setup work on the Java main / UI thread before theandroid_mainRust code starts running.
For example:
use std::sync::OnceLock; use android_activity::OnCreateState; use jni::{JavaVM, refs::Global, objects::JObject}; #[unsafe(no_mangle)] fn android_on_create(state: &OnCreateState) { static APP_ONCE: OnceLock<()> = OnceLock::new(); APP_ONCE.get_or_init(|| { // Initialize logging... // // Remember, `android_on_create` may be called multiple times but some // logger crates will panic if initialized multiple times. }); let vm = unsafe { JavaVM::from_raw(state.vm_as_ptr().cast()) }; let activity = state.activity_as_ptr() as jni::sys::jobject; // Although the thread is implicitly already attached (we are inside an onCreate native method) // using `vm.attach_current_thread` here will use the existing attachment, give us an `&Env` // reference and also catch Java exceptions. if let Err(err) = vm.attach_current_thread(|env| -> jni::errors::Result<()> { // SAFETY: // - The `Activity` reference / pointer is at least valid until we return // - By creating a `Cast` we ensure we can't accidentally delete the reference let activity = unsafe { env.as_cast_raw::<JObject>(&activity)? }; // Do something with the activity on the Java main thread... Ok(()) }) { eprintln!("Failed to interact with Android SDK on Java main thread: {err:?}"); } }
- Support for
MotionEventhistory, providing higher fidelity input data for things like stylus input (native-activity+game-activitybackends). (#218)
Changed
- rust-version bumped to 1.85.0 (#193, #219)
- GameActivity updated to 4.4.0 (#191, #240)
ndk-contextis initialized with anApplicationcontext instead of anActivitycontext (#229)
GameActivity 4.4.0 Update
Important: This release is no longer compatible with GameActivity 2.0.2
Android Packaging: Your Android application must be packaged with the corresponding androidX, GameActivity 4.x.x library from Google.
This release has been tested with the
androidx.games:games-activity:4.4.0stable
release, and is backwards
compatible with the 4.0.0 stable release.If you use Gradle to build your Android application, you can depend on the 4.4.0 release of the GameActivity library via:
dependencies { implementation 'androidx.appcompat:appcompat:1.7.1' // To use the Games Activity library implementation "androidx.games:games-activity:4.4.0" // Note: don't include game-text-input separately, since it's integrated into game-activity }
Note: there is no guarantee that later 4.x.x releases of GameActivity will be compatible with this release of
android-activity, so please refer to theandroid-activityrelease notes for any future updates regarding
GameActivity compatibility.Initializing
ndk-contextwith an Application Contextndk-contextis a separate, framework-independent crate that provides a way for library crates to access a Java VM pointer and anandroid.content.ContextJNI reference without needing to depend onandroid-activitydirectly.ndk-contextmay be initialized by various framework crates, includingandroid-activity, on behalf of library crates.Historically
android-activityhas initializedndk-contextwith anActivitycontext since that was the simplest choice considering that the entrypoint forandroid-activitycomes from anActivityonCreatecallback.However, in retrospect it was realized that this was a short-sighted mistake when considering that:
ndk-contextonly provides a single, global context reference for the entire application that can't be updated- An Android application can have multiple
Activityinstances over its lifetime (and at times could have noActivityinstances at all, e.g. if the app is running a backgroundService) - Whatever is put into
ndk-contextneeds to leak a corresponding global reference to ensure it remains valid to access safely. This is inappropriate for anActivityreference since it can be destroyed and recreated multiple times over the lifetime of the application.
A far better choice, that aligns with the global nature of the
ndk-contextAPI is to initialize it with anApplicationcontext which is valid for the entire lifetime of the application.Note: Although the
ndk-contextAPI only promises to provide anandroid.content.Contextand specifically warns that user's should not assume the context is anActivity, there is still some risk that some users ofndk-contextcould be affected by the change made in #229.For example, until recently the
webbrowsercrate (for opening URLs) was assuming it could access anActivitycontext viandk-context. In preparation for making this change,webbrowserwas updated to ensure it is agnostic to the type of context provided byndk-context, see: amodm/webbrowser-rs#111Other notable library crates that support Android (such as
app_dirs2) are expected to be unaffected by this, since they already operate in terms of theandroid.content.ContextAPI, not theActivityAPI._Note:: if some crate really needs an
Activityreference then they should ideally be able to get one via the
AndroidApp::activity_as_ptr()API. They may need to add some Android-specific initialization API, similar to how Winit has a dedicated.with_android_app()API. An Android-specific init API that could accept a JNI reference to anActivitycould avoid needing to specifically depend onandroid-activity.Fixed
- Safety
AndroidApp::asset_manager()returns anAssetManagerthat has a safe'staticlifetime that's not invalidated whenandroid_main()returns (#233) - Safety The
native-activitybackend clears itsANativeActivityptr afteronDestroyandAndroidAppremains safe to access afterandroid_main()returns (#234) - Safety
AndroidApp::activity_as_ptr()returns a pointer to a global reference that remains valid untilAndroidAppis dropped, instead of theANativeActivity'sclazzpointer which is only guaranteed to be valid untilonDestroyreturns (native-activitybackend) (#234) - Safety The
game-activitybackend clears itsandroid_appptr afteronDestroyandAndroidAppremains safe to access afterandroid_main()returns (#236) - Support for
AndroidApp::show/hide_soft_input()APIs in thenative-activitybackend (#178)
Overall, some effort was made to ensure that
android-activitycan gracefully and safely handle cases where theActivitygets repeatedly created, destroyed and recreated (e.g due to configuration changes). Theoretically it should even be possible to run multipleActivityinstances (although that's not really something thatNativeActivityorGameActivityare designed for).New Contributors
- @jb55 made their first contribution in #191
- @madsmtm made their first contribution in #199
- @atouchet made their first contribution in #220
- @markkimsal made their first contribution in #198
- @jancespivo made their first contribution in #178
Full Changelog: v0.6.0...v0.6.1
Release notes
Open source →Added
- input:
TextInputActionenum representing action button types on soft keyboards. (#216) - input:
InputEvent::TextActionevent for handling action button presses from soft keyboards. (#216) - The
ndkandndk-syscrates are now re-exported underandroid_activity::ndkandandroid_activity::ndk_sys(#194) AndroidApp::java_main_looper()gives access to theALooperfor the Java main / UI thread (#198)AndroidApp::run_on_java_main_thread()can be used to run boxed closures on the Java main / UI thread (#232)- Support for an optional
android_on_createentry point that gets called from theActivity.onCreate()callback beforeandroid_main()is called, allowing for doing some setup work on the Java main / UI thread before theandroid_mainRust code starts running.
For example:
use std::sync::OnceLock; use android_activity::OnCreateState; use jni::{JavaVM, refs::Global, objects::JObject}; #[unsafe(no_mangle)] fn android_on_create(state: &OnCreateState) { static APP_ONCE: OnceLock<()> = OnceLock::new(); APP_ONCE.get_or_init(|| { // Initialize logging... // // Remember, `android_on_create` may be called multiple times but some // logger crates will panic if initialized multiple times. }); let vm = unsafe { JavaVM::from_raw(state.vm_as_ptr().cast()) }; let activity = state.activity_as_ptr() as jni::sys::jobject; // Although the thread is implicitly already attached (we are inside an onCreate native method) // using `vm.attach_current_thread` here will use the existing attachment, give us an `&Env` // reference and also catch Java exceptions. if let Err(err) = vm.attach_current_thread(|env| -> jni::errors::Result<()> { // SAFETY: // - The `Activity` reference / pointer is at least valid until we return // - By creating a `Cast` we ensure we can't accidentally delete the reference let activity = unsafe { env.as_cast_raw::<JObject>(&activity)? }; // Do something with the activity on the Java main thread... Ok(()) }) { eprintln!("Failed to interact with Android SDK on Java main thread: {err:?}"); } }- Support for
MotionEventhistory, providing higher fidelity input data for things like stylus input (native-activity+game-activitybackends). (#218)
Changed
- rust-version bumped to 1.85.0 (#193, #219)
- GameActivity updated to 4.4.0 (#191, #240)
ndk-contextis initialized with anApplicationcontext instead of anActivitycontext (#229)
GameActivity 4.4.0 Update
Important: This release is no longer compatible with GameActivity 2.0.2
Android Packaging: Your Android application must be packaged with the corresponding androidX, GameActivity 4.x.x library from Google.
This release has been tested with the
androidx.games:games-activity:4.4.0stable release, and is backwards compatible with the 4.0.0 stable release.If you use Gradle to build your Android application, you can depend on the 4.4.0 release of the GameActivity library via:
dependencies { implementation 'androidx.appcompat:appcompat:1.7.1' // To use the Games Activity library implementation "androidx.games:games-activity:4.4.0" // Note: don't include game-text-input separately, since it's integrated into game-activity }Note: there is no guarantee that later 4.x.x releases of GameActivity will be compatible with this release of
android-activity, so please refer to theandroid-activityrelease notes for any future updates regarding GameActivity compatibility.Initializing
ndk-contextwith an Application Contextndk-contextis a separate, framework-independent crate that provides a way for library crates to access a Java VM pointer and anandroid.content.ContextJNI reference without needing to depend onandroid-activitydirectly.ndk-contextmay be initialized by various framework crates, includingandroid-activity, on behalf of library crates.Historically
android-activityhas initializedndk-contextwith anActivitycontext since that was the simplest choice considering that the entrypoint forandroid-activitycomes from anActivityonCreatecallback.However, in retrospect it was realized that this was a short-sighted mistake when considering that:
ndk-contextonly provides a single, global context reference for the entire application that can't be updated- An Android application can have multiple
Activityinstances over its lifetime (and at times could have noActivityinstances at all, e.g. if the app is running a backgroundService) - Whatever is put into
ndk-contextneeds to leak a corresponding global reference to ensure it remains valid to access safely. This is inappropriate for anActivityreference since it can be destroyed and recreated multiple times over the lifetime of the application.
A far better choice, that aligns with the global nature of the
ndk-contextAPI is to initialize it with anApplicationcontext which is valid for the entire lifetime of the application.Note: Although the
ndk-contextAPI only promises to provide anandroid.content.Contextand specifically warns that user's should not assume the context is anActivity, there is still some risk that some users ofndk-contextcould be affected by the change made in #229.For example, until recently the
webbrowsercrate (for opening URLs) was assuming it could access anActivitycontext viandk-context. In preparation for making this change,webbrowserwas updated to ensure it is agnostic to the type of context provided byndk-context, see: https://github.com/amodm/webbrowser-rs/pull/111Other notable library crates that support Android (such as
app_dirs2) are expected to be unaffected by this, since they already operate in terms of theandroid.content.ContextAPI, not theActivityAPI._Note:: if some crate really needs an
Activityreference then they should ideally be able to get one via theAndroidApp::activity_as_ptr()API. They may need to add some Android-specific initialization API, similar to how Winit has a dedicated.with_android_app()API. An Android-specific init API that could accept a JNI reference to anActivitycould avoid needing to specifically depend onandroid-activity.Fixed
- Safety
AndroidApp::asset_manager()returns anAssetManagerthat has a safe'staticlifetime that's not invalidated whenandroid_main()returns (#233) - Safety The
native-activitybackend clears itsANativeActivityptr afteronDestroyandAndroidAppremains safe to access afterandroid_main()returns (#234) - Safety
AndroidApp::activity_as_ptr()returns a pointer to a global reference that remains valid untilAndroidAppis dropped, instead of theANativeActivity'sclazzpointer which is only guaranteed to be valid untilonDestroyreturns (native-activitybackend) (#234) - Safety The
game-activitybackend clears itsandroid_appptr afteronDestroyandAndroidAppremains safe to access afterandroid_main()returns (#236) - Support for
AndroidApp::show/hide_soft_input()APIs in thenative-activitybackend (#178)
Overall, some effort was made to ensure that
android-activitycan gracefully and safely handle cases where theActivitygets repeatedly created, destroyed and recreated (e.g due to configuration changes). Theoretically it should even be possible to run multipleActivityinstances (although that's not really something thatNativeActivityorGameActivityare designed for). - input:
-
0.6.026 Apr 2024Release notes
Open source →What's Changed
- Bump MSRV to 1.69.0 considering we can't build cargo ndk with 1.68 by @rib in #156
- Upgrade to
ndk-sys 0.6.0andndk 0.9.0by @MarijnS95 in #155 - native-activity: Check for null
saved_state_inpointer by @skibon02 in #157 - Release 0.6.0 by @rib in #158
New Contributors
Full Changelog: v0.5.2...v0.6.0
-
0.5.230 Jan 2024Release notes
Open source →What's Changed
- native-activity/input: AND with
EVENT_ACTION_MASKwhen extracting MotionEvent action by @ArthurCose in #147
New Contributors
- @ArthurCose made their first contribution in #147
Full Changelog: v0.5.1...v0.5.2
- native-activity/input: AND with
-
0.5.120 Dec 2023Release notes
Open source →Changed
-
Avoids depending on default features for
ndkcrate to avoid pulling in anyraw-window-handledependencies (#142)Note: Technically, this could be observed as a breaking change in case you were depending on the
rwh_06feature that was enabled by default in thendkcrate. This could be observed via theNativeWindowtype (exposed viaAndroidApp::native_window()) no longer implementingrwh_06::HasWindowHandle.In the unlikely case that you were depending on the
ndk'srwh_06API being enabled by default viaandroid-activity'sndkdependency, your crate should explicitly enable therwh_06feature for thendkcrate.As far as could be seen though, it's not expected that anything was depending on this (e.g. anything based on Winit enables the
ndkfeature based on an equivalentwinitfeature).The benefit of the change is that it can help avoid a redundant
raw-window-handle 0.6dependency in projects that still need to use older (non-default)raw-window-handleversions. (Though note that this may be awkward to achieve in practice since other crates that depend on thendkare still likely to use default features and also pull inraw-window-handles 0.6) -
The IO thread now gets named
stdio-to-logcatand main thread is namedandroid_main(#145) -
Improved IO error handling in
stdio-to-logcatIO loop. (#133)
New Contributors
Full Changelog: v0.5.0...v0.5.1
Release notes
Open source →Changed
-
Avoids depending on default features for
ndkcrate to avoid pulling in anyraw-window-handledependencies (#142)Note: Technically, this could be observed as a breaking change in case you were depending on the
rwh_06feature that was enabled by default in thendkcrate. This could be observed via theNativeWindowtype (exposed viaAndroidApp::native_window()) no longer implementingrwh_06::HasWindowHandle.In the unlikely case that you were depending on the
ndk'srwh_06API being enabled by default viaandroid-activity'sndkdependency, your crate should explicitly enable therwh_06feature for thendkcrate.As far as could be seen though, it's not expected that anything was depending on this (e.g. anything based on Winit enables the
ndkfeature based on an equivalentwinitfeature).The benefit of the change is that it can help avoid a redundant
raw-window-handle 0.6dependency in projects that still need to use older (non-default)raw-window-handleversions. (Though note that this may be awkward to achieve in practice since other crates that depend on thendkare still likely to use default features and also pull inraw-window-handles 0.6) -
The IO thread now gets named
stdio-to-logcatand main thread is namedandroid_main(#145) -
Improved IO error handling in
stdio-to-logcatIO loop. (#133)
-
-
0.5.016 Oct 2023Release notes
Open source →Probably the most notable (breaking) change in this release is the updated API for reading input events to better support being able to use other
AndroidAppAPIs while iterating input events, to support unicode character mapping forKeycodes.The other big change with this release is the update of the
game-activitybackend, updating to GameActivity 2.0.2. Applications using thegame-activitybackend will need to ensure they pull in the corresponding 2.0.2.aarfrom Google (For example, see https://github.com/rust-mobile/android-activity/blob/main/examples/agdk-mainloop/app/build.gradle)Added
-
Added
KeyEvent::meta_state()for being able to query the state of meta keys, needed for character mapping (#102) -
Added
KeyCharacterMapJNI bindings to the corresponding Android SDK API (#102) -
Added
Click here for an example of how to handle unicode character mapping:AndroidApp::device_key_character_map()for being able to get aKeyCharacterMapfor a givendevice_idfor unicode character mapping (#102)let mut combining_accent = None; // Snip let combined_key_char = if let Ok(map) = app.device_key_character_map(device_id) { match map.get(key_event.key_code(), key_event.meta_state()) { Ok(KeyMapChar::Unicode(unicode)) => { let combined_unicode = if let Some(accent) = combining_accent { match map.get_dead_char(accent, unicode) { Ok(Some(key)) => { info!("KeyEvent: Combined '{unicode}' with accent '{accent}' to give '{key}'"); Some(key) } Ok(None) => None, Err(err) => { log::error!("KeyEvent: Failed to combine 'dead key' accent '{accent}' with '{unicode}': {err:?}"); None } } } else { info!("KeyEvent: Pressed '{unicode}'"); Some(unicode) }; combining_accent = None; combined_unicode.map(|unicode| KeyMapChar::Unicode(unicode)) } Ok(KeyMapChar::CombiningAccent(accent)) => { info!("KeyEvent: Pressed 'dead key' combining accent '{accent}'"); combining_accent = Some(accent); Some(KeyMapChar::CombiningAccent(accent)) } Ok(KeyMapChar::None) => { info!("KeyEvent: Pressed non-unicode key"); combining_accent = None; None } Err(err) => { log::error!("KeyEvent: Failed to get key map character: {err:?}"); combining_accent = None; None } } } else { None };
-
Added
TextEventInput Method event for supporting text editing via virtual keyboards (#24) -
Added
MotionEvent::action_button()exposing the button associated with button press/release actions (#138)
Changed
-
rust-version bumped to 0.68 (#123)
-
Breaking: update to
ndk 0.8andndk-sys 0.5(#128) -
GameActivity updated to 2.0.2 (requires the corresponding 2.0.2
.aarrelease from Google) (#88) -
Click here for an example of how to use `input_events_iter()`:AndroidApp::input_events()is replaced byAndroidApp::input_events_iter()(#102)match app.input_events_iter() { Ok(mut iter) => { loop { let read_input = iter.next(|event| { let handled = match event { InputEvent::KeyEvent(key_event) => { // Snip } InputEvent::MotionEvent(motion_event) => { // Snip } event => { // Snip } }; handled }); if !read_input { break; } } } Err(err) => { log::error!("Failed to get input events iterator: {err:?}"); } }
-
The
PointerandPointerItertypes from thendkcrate are no longer directly exposed in the public API (#122) -
All input API enums based on Android SDK enums have been made runtime extensible via hidden
__Unknown(u32)variants (#131)
New Contributors
- @lexi-the-cute made their first contribution in #88
- @daxpedda made their first contribution in #85
- @fornwall made their first contribution in #124
Full Changelog: v0.4.3...v0.5.0
Release notes
Open source →Added
- Added
MotionEvent::action_button()exposing the button associated with button press/release actions (#138)
Changed
- rust-version bumped to 0.68 (#123)
- Breaking: updates to
ndk 0.8andndk-sys 0.5(#128) - The
PointerandPointerItertypes from thendkcrate are no longer directly exposed in the public API (#122) - All input API enums based on Android SDK enums have been made runtime extensible via hidden
__Unknown(u32)variants (#131)
-
-
0.5.0-beta.115 Aug 2023 pre-releaseRelease notes
Open source →This only updates the
ndkandndk-sysdependencies to pull inndk 0.8.0-beta.0andndk-sys 0.5.0-beta.0 -
0.5.0-beta.015 Aug 2023 pre-releaseRelease notes
Open source →This is the first 0.5.0 beta that's aiming to be ready for the upcoming Winit 0.29 release
The main reason that a (breaking) semver bump was required was so we could update the API for reading input events to better support being able to use other AndroidApp APIs while iterating input events, to support unicode character mapping for Keycodes.
A big change with this release is the update of the
game-activitybackend, updating to GameActivity 2.0.2. Applications using thegame-activitybackend will need to ensure they pull in the corresponding 2.0.2.aarfrom Google (For example, see https://github.com/rust-mobile/android-activity/blob/main/examples/agdk-mainloop/app/build.gradle)Added
-
Added
KeyEvent::meta_state()for being able to query the state of meta keys, needed for character mapping (#102) -
Added
KeyCharacterMapJNI bindings to the corresponding Android SDK API (#102) -
Added
Click here for an example of how to handle unicode character mapping:AndroidApp::device_key_character_map()for being able to get aKeyCharacterMapfor a givendevice_idfor unicode character mapping (#102)let mut combining_accent = None; // Snip let combined_key_char = if let Ok(map) = app.device_key_character_map(device_id) { match map.get(key_event.key_code(), key_event.meta_state()) { Ok(KeyMapChar::Unicode(unicode)) => { let combined_unicode = if let Some(accent) = combining_accent { match map.get_dead_char(accent, unicode) { Ok(Some(key)) => { info!("KeyEvent: Combined '{unicode}' with accent '{accent}' to give '{key}'"); Some(key) } Ok(None) => None, Err(err) => { log::error!("KeyEvent: Failed to combine 'dead key' accent '{accent}' with '{unicode}': {err:?}"); None } } } else { info!("KeyEvent: Pressed '{unicode}'"); Some(unicode) }; combining_accent = None; combined_unicode.map(|unicode| KeyMapChar::Unicode(unicode)) } Ok(KeyMapChar::CombiningAccent(accent)) => { info!("KeyEvent: Pressed 'dead key' combining accent '{accent}'"); combining_accent = Some(accent); Some(KeyMapChar::CombiningAccent(accent)) } Ok(KeyMapChar::None) => { info!("KeyEvent: Pressed non-unicode key"); combining_accent = None; None } Err(err) => { log::error!("KeyEvent: Failed to get key map character: {err:?}"); combining_accent = None; None } } } else { None };
-
Added
TextEventInput Method event for supporting text editing via virtual keyboards (#24)
Changed
-
GameActivity updated to 2.0.2 (requires the corresponding 2.0.2
.aarrelease from Google) (#88) -
Click here for an example of how to use `input_events_iter()`:AndroidApp::input_events()is replaced byAndroidApp::input_events_iter()(#102)match app.input_events_iter() { Ok(mut iter) => { loop { let read_input = iter.next(|event| { let handled = match event { InputEvent::KeyEvent(key_event) => { // Snip } InputEvent::MotionEvent(motion_event) => { // Snip } event => { // Snip } }; handled }); if !read_input { break; } } } Err(err) => { log::error!("Failed to get input events iterator: {err:?}"); } }
New Contributors
- @lexi-the-cute made their first contribution in #88
- @daxpedda made their first contribution in #85
Full Changelog: v0.4.3...v0.5.0-beta.0
Release notes
Open source →Added
-
Added
KeyEvent::meta_state()for being able to query the state of meta keys, needed for character mapping (#102) -
Added
KeyCharacterMapJNI bindings to the corresponding Android SDK API (#102) -
Added
AndroidApp::device_key_character_map()for being able to get aKeyCharacterMapfor a givendevice_idfor unicode character mapping (#102)<details> <summary>Click here for an example of how to handle unicode character mapping:</summary>
let mut combining_accent = None; // Snip let combined_key_char = if let Ok(map) = app.device_key_character_map(device_id) { match map.get(key_event.key_code(), key_event.meta_state()) { Ok(KeyMapChar::Unicode(unicode)) => { let combined_unicode = if let Some(accent) = combining_accent { match map.get_dead_char(accent, unicode) { Ok(Some(key)) => { info!("KeyEvent: Combined '{unicode}' with accent '{accent}' to give '{key}'"); Some(key) } Ok(None) => None, Err(err) => { log::error!("KeyEvent: Failed to combine 'dead key' accent '{accent}' with '{unicode}': {err:?}"); None } } } else { info!("KeyEvent: Pressed '{unicode}'"); Some(unicode) }; combining_accent = None; combined_unicode.map(|unicode| KeyMapChar::Unicode(unicode)) } Ok(KeyMapChar::CombiningAccent(accent)) => { info!("KeyEvent: Pressed 'dead key' combining accent '{accent}'"); combining_accent = Some(accent); Some(KeyMapChar::CombiningAccent(accent)) } Ok(KeyMapChar::None) => { info!("KeyEvent: Pressed non-unicode key"); combining_accent = None; None } Err(err) => { log::error!("KeyEvent: Failed to get key map character: {err:?}"); combining_accent = None; None } } } else { None };</details>
-
Added
TextEventInput Method event for supporting text editing via virtual keyboards (#24)
Changed
-
GameActivity updated to 2.0.2 (requires the corresponding 2.0.2
.aarrelease from Google) (#88) -
AndroidApp::input_events()is replaced byAndroidApp::input_events_iter()(#102)<details> <summary>Click here for an example of how to use
input_events_iter():</summary>match app.input_events_iter() { Ok(mut iter) => { loop { let read_input = iter.next(|event| { let handled = match event { InputEvent::KeyEvent(key_event) => { // Snip } InputEvent::MotionEvent(motion_event) => { // Snip } event => { // Snip } }; handled }); if !read_input { break; } } } Err(err) => { log::error!("Failed to get input events iterator: {err:?}"); } }</details>
-
-
0.4.330 Jul 2023Release notes
Open source →What's Changed
- Fix deadlock on activity onDestroy by @sagebind in #94
- GameActivity PATCH: fix deadlocks in java callbacks after app destroyed by @rib in #98
New Contributors
Full Changelog: v0.4.2...v0.4.3
Release notes
Open source →Fixed
- Fixed a deadlock in the
native-activitybackend while waiting for the native thread after getting anonDestroycallback from Java (#94) - Fixed numerous deadlocks in the
game-activitybackend with how it would wait for the native thread in various Java callbacks, after the app has returned fromandroid_main(#98)
-
0.4.227 Jun 2023Release notes
Open source →What's Changed
- Add dependabot support by @notgull in #72
- native-activity: Propagate
NativeWindowredraw/resize andContentRectChangedcallbacks to main loop by @MarijnS95 in #70 - Add MSRV policy to README and bump
rust_versionto 1.64, due tondk->raw_window_handledependency by @rib in #76 - build(deps): update num_enum requirement from 0.5 to 0.6 by @dependabot in #74
- build(deps): bump actions/checkout from 2 to 3 by @dependabot in #73
- Fix rust_version typo s/0.64/1.64/ by @rib in #77
- Add panic guards to extern "C" functions by @notgull in #68
- game_activity: Fix
pointer_index()always returning0by @yunsash in #84 - README: Add badges to CI, crates.io, docs.rs and show the MSRV by @MarijnS95 in #86
- Call Activity.finish() when android_main returns by @rib in #81
- cargo: Fix
rust_version->rust-versionproperty typo by @MarijnS95 in #87 - Release 0.4.2 by @rib in #90
New Contributors
- @notgull made their first contribution in #72
- @dependabot made their first contribution in #74 - good bot 🤖
- @yunsash made their first contribution in #84
Full Changelog: v0.4.1...v0.4.2
Release notes
Open source →Changed
- The
Activity.finish()method is now called whenandroid_mainreturns so theActivitywill be destroyed (#67) - The
native-activitybackend now propagatesNativeWindowredraw/resize andContentRectChangedcallbacks to main loop (#70) - The
game-activityimplementation ofpointer_index()was fixed to not always return0(#80) - Added
panicguards around application'sandroid_main()and native code that could potentially unwind across a Java FFI boundary (#68)
-
0.4.115 Feb 2023Release notes
Open source →What's Changed
Added
- Added
AndroidApp::vm_as_ptr()to expose JNIJavaVMpointer (#60) - Added
AndroidApp::activity_as_ptr()to expose AndroidActivityJNI reference as pointer (#60)
Changed
- Removed some overly-verbose logging in the
native-activitybackend (#49)
Removed
- Most of the examples were moved to https://github.com/rust-mobile/rust-android-examples (#50)
New Contributors
- @MarijnS95 made their first contribution in #47
Full Changelog: v0.4.0...v0.4.1
Release notes
Open source →Added
- Added
AndroidApp::vm_as_ptr()to expose JNIJavaVMpointer (#60) - Added
AndroidApp::activity_as_ptr()to expose AndroidActivityJNI reference as pointer (#60)
Changed
- Removed some overly-verbose logging in the
native-activitybackend (#49)
Removed
- Most of the examples were moved to https://github.com/rust-mobile/rust-android-examples (#50)
- Added
-
0.4.014 Nov 2022Release notes
Open source →Changed
- Breaking:
input_eventscallback now return whether an event was handled or not to allow for fallback handling (#31) - The native-activity backend is now implemented in Rust only, without building on
android_native_app_glue.c(#35)
Added
- Added
Pointer::tool_type()API toGameActivitybackend for compatibility withndkevents API (#38)
- Breaking:
-
0.4.0-beta.111 Oct 2022 pre-releaseNothing published for this version
-
0.4.0-beta20 Sep 2022 pre-releaseNothing published for this version
-
0.3.017 Sep 2022Release notes
Open source →Added
show/hide_sot_inputAPI for being able to show/hide a soft keyboard (other IME still pending)set_window_flags()API for setting WindowManager params
Changed
- Breaking: Created extensible,
#[non_exhaustive]InputEventwrapper enum instead of exposingndktype directly
-
0.2.025 Aug 2022Release notes
Open source →Added
- Emit an
InputAvailableevent for new input withNativeActivityandGameActivityenabling gui apps that don't render continuously - Oboe and Cpal audio examples added
AndroidAppis nowSend+Sync
Changed
- Breaking: updates to
ndk 0.7andndk-sys 0.4 - Breaking:
AndroidApp::config()now returns a clonableConfigurationRefinstead of a deepConfigurationcopy
Removed
- The
NativeWindowRefwrapper struct was removed sinceNativeWindownow implementsCloneandDropinndk 0.7 - Breaking: The
FdEventandErrorenum values were removed fromPollEvents
- Emit an
-
0.1.104 Jul 2022 -
0.1.003 Jul 2022