Android-ndk-rs, Can I open up the camera and other things?

Hey guys, I wanted to know, does android-ndk-rs can do the following:

  1. Open up the camera
  2. Unlock some part of an app using biometrics?

Not sure if it's possible even with original NDK - the only thing I was able to find with brief search was this page.

This is a separate library, not directly accessible from NDK (well, I'm not sure if NDK can call into arbitrary Java classes, but in the explicitly stated API seems to be no reference there).

1 Like
  1. Technically it's possible.
  2. Practically, I would advise strongly against trying that.

Most UI-related Android APIs are designed to be used from Java.

It's possible to access it from C++ or Rust, but practically it's much easier to just write some Java shim which does UI (or just interacts with the rest of the Android system) in Java and write logic in Rust or C++.

P.S. Note that some other Android APIs (NN APIs, Vulkan and some others) are very hard to access from Java. Which means that most non-trial apps have two layers: C++ layer (where you can use Rust if you want) and Java layer (where you can use Kotlin if you want). Trying to shoehorn everything in one language is not really feasible.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.