首页
IT
登录
6mi
u
盘
搜
搜 索
IT
JNI修改Native方法数组参数中数组里面的元素值
JNI修改Native方法数组参数中数组里面的元素值
xiaoxiao
2021-03-26
35
JNIEXPORT
jintArray
JNICALL
Java_com_example_feisou_a02_1helloworld_JNI_arrElementsIncrease (
JNIEnv
*env
,
jobject
thiz
,
jintArray
jarray){
jsize
length = (*env)->
GetArrayLength
(env
,
jarray)
;
LOGD
(
"length = %d"
,
length)
;
//jboolean iscopy;
jint
* arrayPointer = (*env)->
GetIntArrayElements
(env
,
jarray
,
NULL
)
;
int
i
;
for
(i=
0
;
i<length
;
i++){ *(arrayPointer+i) +=
10
;
} (*env)->
SetIntArrayRegion
(env
,
jarray
,
0
,
length
,
arrayPointer)
;
return
jarray
;
}
public void
click2
(View V){
int
[] array =
new int
[]{
1
,
2
,
3
,
4
,
5
}
;
for
(
int
i:
jni
.arrElementsIncrease(array)){ Log.
d
(
"test"
,
i+
""
)
;
}
}
转载请注明原文地址: https://ju.6miu.com/read-659250.html
技术
最新回复
(
0
)