1//! Platform specific types.
23/// Android backend.
4///
5/// See [`winit::platform::android`](https://docs.rs/winit/latest/winit/platform/android/) for more details
6/// on how to select a backend "Activity".
7#[cfg(target_os = "android")]
8pub mod android {
9pub use winit::platform::android::activity;
1011#[cfg(target_os = "android")]
12static ANDROID_APP: parking_lot::RwLock<Option<activity::AndroidApp>> = parking_lot::RwLock::new(None);
1314/// Sets the [`android_app`] instance for this process and the Android paths.
15 ///
16 /// This must be called just after `zng::env::init!` and before `run_same_process*`.
17#[cfg(target_os = "android")]
18pub fn init_android_app(app: activity::AndroidApp) {
19let internal = app.internal_data_path().unwrap_or_default();
20let external = app.external_data_path().unwrap_or_default();
21 zng_env::init_android_paths(internal, external);
22*ANDROID_APP.write() = Some(app);
23 }
2425/// Gets the `AndroidApp` instance for this process.
26 ///
27 /// Panics if called before [`init_android_app`].
28#[cfg(target_os = "android")]
29pub fn android_app() -> activity::AndroidApp {
30 ANDROID_APP
31 .read()
32 .clone()
33 .expect("android_app is only available after `init_android_app` call")
34 }
35}