Function slint::android::init_with_event_listener
source · pub fn init_with_event_listener(
app: AndroidApp,
listener: impl Fn(&PollEvent<'_>) + 'static,
) -> Result<(), SetPlatformError>
Expand description
Similar to init()
, which allow to listen to android-activity’s event
Note: This function is only available on Android with the “backend-android-activity-06” feature
The listener argument is a function that takes a android_activity::PollEvent
§Example
#[no_mangle]
fn android_main(app: slint::android_activity::AndroidApp) {
slint::android_init_with_event_listener(
app,
|event| { eprintln!("got event {event:?}") }
).unwrap();
// ... rest of your application ...
}
Check out the module documentation for a more complete example on how to write an android application