From 172b34a8d51b62704fed2e7f6efe1b6e1811ee19 Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Thu, 30 May 2024 19:53:06 +0800 Subject: [PATCH] Crash fixing on Android --- src/android.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/android.rs b/src/android.rs index 65c38cb..07bd49d 100644 --- a/src/android.rs +++ b/src/android.rs @@ -209,10 +209,8 @@ pub mod native { 0 } - unsafe fn get_java_string<'a>(env: &'a mut JNIEnv, string: &'a JString) -> Result<&'a str> { - let str_ptr = env.get_string(string)?.as_ptr(); - let s: &str = std::ffi::CStr::from_ptr(str_ptr).to_str()?; - Ok(s) + fn get_java_string(env: &mut JNIEnv, string: &JString) -> Result { + Ok(env.get_string(string)?.into()) } /// # Safety