add android NDK event loop (#1556)

* add android NDK event loop

* add Android build documentation & cargo-apk to CI

Co-authored-by: David Craven <david@craven.ch>
This commit is contained in:
Jasper De Sutter 2020-05-06 15:27:49 +02:00 committed by GitHub
parent 007b195a5e
commit b8828105cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 532 additions and 546 deletions

View file

@ -76,3 +76,22 @@ Building a binary will yield a `.js` file. In order to use it in an HTML file, y
the element of the `<canvas>` element (in the example you would retrieve it via `document.getElementById("my_id")`).
More information [here](https://kripken.github.io/emscripten-site/docs/api_reference/module.html).
- Make sure that you insert the `.js` file generated by Rust after the `Module` variable is created.
#### Android
This library makes use of the [ndk-rs](https://github.com/rust-windowing/android-ndk-rs) crates, refer to that repo for more documentation.
Running on an Android device needs a dynamic system library, add this to Cargo.toml:
```toml
[[example]]
name = "request_redraw_threaded"
crate-type = ["cdylib"]
```
And add this to the example file to add the native activity glue:
```rust
#[cfg(target_os = "android")]
ndk_glue::ndk_glue!(main);
```
And run the application with `cargo apk run --example request_redraw_threaded`