android_glue 0.1.3

Glue for the Android JNI
docs.rs failed to build android_glue-0.1.3
Please check the build logs and, if you believe this is docs.rs' fault, open an issue.

You can make any program run on Android with minimal non-intrusive modification using this library.

See, https://github.com/tomaka/android-rs-glue, for detailed instructions!

The libray allow you to run any program on Android, but it also allows you to work specifically with the Android system if you desire. The following sample application demonstrates both non-os specific code, and android specific code.

A example application:

// This code will only be included if android is the target.
#[cfg(target_os = "android")]
#[macro_use]
extern crate android_glue;
// This code will only be included if android is the target.
#[cfg(target_os = "android")]
android_start!(main);

use std::sync::mpsc::channel;
use android_glue::{Event, add_sender};

#[cfg(target_os = "android")]
fn os_specific() {
    // Create a channel.
    let (eventstx, eventsrx) = channel::<Event>();
    // The following is optional, and will only work if you target Android.
    // Add the sender half of the channel so we can be sent events.
    add_sender(eventstx);
    loop {
        // Print the event since it implements the Debug trait.
        println!("{:?}", eventsrx.recv());
    }
}

#[cfg(not(target_os = "android"))]
fn os_specific() {
    println!("non-android");
}


fn main() {
    // Try `adb logcat *:D | grep RustAndroidGlue` when you run this
    // program on android. If on any other platform it will work as
    // normal.
    println!("HELLO WORLD");
    os_specific();
}