Skip to content

Commit

Permalink
Add android-example.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvc94ch committed Feb 14, 2020
1 parent 12deb7f commit 12a1f55
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
"android-build-tools",
"android-examples",
"android-glue",
"android-ndk-sys",
"android-ndk",
Expand Down
12 changes: 12 additions & 0 deletions android-examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "android-examples"
version = "0.1.0"
authors = ["David Craven <[email protected]>"]
edition = "2018"

[target.'cfg(target_os = "android")'.dependencies]
android-glue = { path = "../android-glue" }

[[example]]
name = "hello_world"
crate-type = ["cdylib"]
19 changes: 19 additions & 0 deletions android-examples/examples/hello_world.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#[cfg(target_os = "android")]
#[no_mangle]
pub unsafe extern "C" fn ANativeActivity_onCreate(
activity: *mut std::os::raw::c_void,
saved_state: *mut std::os::raw::c_void,
saved_state_size: usize,
) {
std::env::set_var("RUST_BACKTRACE", "1");
android_glue::init(
activity as _,
saved_state as _,
saved_state_size as _,
app_main,
);
}

pub fn app_main() {
println!("hello world");
}
1 change: 1 addition & 0 deletions android-examples/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 12a1f55

Please sign in to comment.