forked from Lonami/Talaria
21 lines
560 B
Rust
21 lines
560 B
Rust
#![cfg(target_os = "android")]
|
|
#![allow(non_snake_case)]
|
|
|
|
use std::ffi::{CStr, CString};
|
|
|
|
use jni::JNIEnv;
|
|
use jni::objects::{JObject, JString};
|
|
use jni::sys::jstring;
|
|
|
|
#[no_mangle]
|
|
pub unsafe extern fn Java_dev_lonami_talaria_MainActivity_hello(env: JNIEnv, _: JObject, j_recipient: JString) -> jstring {
|
|
let recipient = CString::from(
|
|
CStr::from_ptr(
|
|
env.get_string(j_recipient).unwrap().as_ptr()
|
|
)
|
|
);
|
|
|
|
let output = env.new_string("Hello ".to_owned() + recipient.to_str().unwrap()).unwrap();
|
|
output.into_inner()
|
|
}
|