13
13
//! a wider range of devices.
14
14
//!
15
15
//! Standalone applications based on this crate need to be built as `cdylib` libraries, like:
16
- //! ```
16
+ //! ```toml
17
17
//! [lib]
18
18
//! crate_type=["cdylib"]
19
19
//! ```
20
20
//!
21
21
//! and implement a `#[no_mangle]` `android_main` entry point like this:
22
- //! ```rust
22
+ //! ```
23
23
//! #[no_mangle]
24
- //! fn android_main(app: AndroidApp) {
24
+ //! fn android_main(app: android_activity:: AndroidApp) {
25
25
//!
26
26
//! }
27
27
//! ```
64
64
//! These are undone after `android_main()` returns
65
65
//!
66
66
//! # Android Extensible Enums
67
+ // TODO: Move this to the NDK crate, which now implements this for most of the code?
67
68
//!
68
69
//! There are numerous enums in the `android-activity` API which are effectively
69
70
//! bindings to enums declared in the Android SDK which need to be considered
95
96
//! For example, here is how you could ensure forwards compatibility with both
96
97
//! compile-time and runtime extensions of a `SomeEnum` enum:
97
98
//!
98
- //! ```rust
99
+ //! ```ignore
99
100
//! match some_enum {
100
101
//! SomeEnum::Foo => {},
101
102
//! SomeEnum::Bar => {},
@@ -131,7 +132,7 @@ use ndk::native_window::NativeWindow;
131
132
pub use ndk;
132
133
pub use ndk_sys;
133
134
134
- #[ cfg( not( target_os = "android" ) ) ]
135
+ #[ cfg( all ( not( target_os = "android" ) , not ( feature = "test" ) ) ) ]
135
136
compile_error ! ( "android-activity only supports compiling for Android" ) ;
136
137
137
138
#[ cfg( all( feature = "game-activity" , feature = "native-activity" ) ) ]
@@ -556,10 +557,10 @@ impl AndroidApp {
556
557
/// between native Rust code and Java/Kotlin code running within the JVM.
557
558
///
558
559
/// If you use the [`jni`] crate you can wrap this as a [`JavaVM`] via:
559
- /// ```ignore
560
+ /// ```no_run
560
561
/// # use jni::JavaVM;
561
- /// # let app: AndroidApp = todo!();
562
- /// let vm = unsafe { JavaVM::from_raw(app.vm_as_ptr()) };
562
+ /// # let app: android_activity:: AndroidApp = todo!();
563
+ /// let vm = unsafe { JavaVM::from_raw(app.vm_as_ptr().ast() ) };
563
564
/// ```
564
565
///
565
566
/// [`jni`]: https://crates.io/crates/jni
@@ -571,10 +572,10 @@ impl AndroidApp {
571
572
/// Returns a JNI object reference for this application's JVM `Activity` as a pointer
572
573
///
573
574
/// If you use the [`jni`] crate you can wrap this as an object reference via:
574
- /// ```ignore
575
+ /// ```no_run
575
576
/// # use jni::objects::JObject;
576
- /// # let app: AndroidApp = todo!();
577
- /// let activity = unsafe { JObject::from_raw(app.activity_as_ptr()) };
577
+ /// # let app: android_activity:: AndroidApp = todo!();
578
+ /// let activity = unsafe { JObject::from_raw(app.activity_as_ptr().cast() ) };
578
579
/// ```
579
580
///
580
581
/// # JNI Safety
@@ -731,7 +732,7 @@ impl AndroidApp {
731
732
/// # Example
732
733
/// Code to iterate all pending input events would look something like this:
733
734
///
734
- /// ```rust
735
+ /// ```
735
736
/// match app.input_events_iter() {
736
737
/// Ok(mut iter) => {
737
738
/// loop {
@@ -786,7 +787,7 @@ impl AndroidApp {
786
787
///
787
788
/// Code to handle unicode character mapping as well as combining dead keys could look some thing like:
788
789
///
789
- /// ```rust
790
+ /// ```
790
791
/// let mut combining_accent = None;
791
792
/// // Snip
792
793
///
0 commit comments