转换JNI类型本地类型 [英] Convert JNI types to Native types

查看:345
本文介绍了转换JNI类型本地类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然有关于转动的jstring到本机的字符串(字符串nativeString = env-> GetStringUTFChars(jStringVariable,NULL); )的文件我找不到例如,将一个jboolean转换为布尔或jint为int。

While there is documentation regarding turning a jstring to a native string (string nativeString = env->GetStringUTFChars(jStringVariable, NULL);) I can't find an example which will convert a jboolean to a bool or a jint to an int.

任何人都可以表明这是如何实现的?

Can anyone suggest how this is achieved?

推荐答案

您只需要投 jint INT 使用C风格的转换。同为 jboolean 布尔(如果你使用C99 布尔输入)或 uint8_t有(如果你使用std int型)或 unsigned char型

You just need to cast jintto int using C style casts. Same for jboolean to bool (if you're using C99 bool type) or to uint8_t (if you're using std int types) or to unsigned char.

打开 $ NDK_ROOT /平台/ Android的-8 /弓臂/ usr / include目录/ jni.h ,你会看到 jint jboolean 等只是的typedef 秒。

Open $NDK_ROOT/platforms/android-8/arch-arm/usr/include/jni.h and you'll see jint, jboolean etc are just typedefs.

这篇关于转换JNI类型本地类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆