2 releases

0.1.1 Apr 19, 2022
0.1.0 Feb 14, 2022

#8 in Android

Download history 257324/week @ 2025-12-13 174542/week @ 2025-12-20 173126/week @ 2025-12-27 302989/week @ 2026-01-03 339297/week @ 2026-01-10 327546/week @ 2026-01-17 340615/week @ 2026-01-24 381807/week @ 2026-01-31 611653/week @ 2026-02-07 617673/week @ 2026-02-14 689971/week @ 2026-02-21 775995/week @ 2026-02-28 864339/week @ 2026-03-07 718837/week @ 2026-03-14 575825/week @ 2026-03-21 572030/week @ 2026-03-28

2,872,692 downloads per month
Used in 5,732 crates (50 directly)

MIT/Apache

6KB

Provides a stable api to rust crates for interfacing with the Android platform. It is initialized by the runtime, usually ndk-glue, but could also be initialized by Java or Kotlin code when embedding in an existing Android project.

let ctx = ndk_context::android_context();
let vm = unsafe { jni::JavaVM::from_raw(ctx.vm().cast()) }?;
let env = vm.attach_current_thread();
let class_ctx = env.find_class("android/content/Context")?;
let audio_service = env.get_static_field(class_ctx, "AUDIO_SERVICE", "Ljava/lang/String;")?;
let audio_manager = env
    .call_method(
        ctx.context() as jni::sys::jobject,
        "getSystemService",
        "(Ljava/lang/String;)Ljava/lang/Object;",
        &[audio_service],
    )?
    .l()?;

ndk-context

Provides a stable api to rust crates for interfacing with the Android platform. It is initialized by the runtime, usually ndk-glue, but could also be initialized by Java or Kotlin code when embedding in an existing Android project.

No runtime deps