Android java传递int类型数组给C
接着前面的文章《Android java传递int类型数据给C》《Android java传递string类型数据给C》,继续实践
实现public native int[] arrElementsIncrease(int[] intArray);
项目布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" > <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="click"
android:text="传递int类型参数" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="passString"
android:text="传递String类型参数" /> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="passIntArray"
android:text="传递Int类型数组" /> </LinearLayout>
实现arrElementsIncrease函数
/*
* Class: com_wuyudong_javapassdata_JNI
* Method: arrElementsIncrease
* Signature: ([I)[I
*/JNIEXPORT jintArray
JNICALL Java_com_wuyudong_javapassdata_JNI_arrElementsIncrease(
JNIEnv * env, jobject clazz, jintArray jArray){
jsize len = (*env)->GetArrayLength(env, jArray);
// jboolean iscopy;
int* arrayPointer = (*env)->GetIntArrayElements(env, jArray, NULL);
int i;
for(i = ; i < len; i++){
*(arrayPointer + i) += ;
}
return jArray; }
MainActivity.java中添加下面的代码:
public void passIntArray(View v) {
int[] array = new int[] { 1, 2, 3, 4, 5 };
int[] newArray = jni.arrElementsIncrease(array);
for (int i : newArray) {
Log.d("test", i + "");
}
}
获取更多C相关知识,关注公众号:“csuanfa”

Android java传递int类型数组给C的更多相关文章
- Android java传递int类型数据给C
本文根据<Android jni简便开发流程>中的开发流程来实现一个java传递int类型数据给C 新建项目,进行简单的布局 <LinearLayout xmlns:android= ...
- Android java传递string类型数据给C
本文接着实现<Android java传递int类型数据给C>的还未实现的方法: public native String sayHelloInC(String s); 先贴一个工具方法, ...
- 75 int类型数组中除了一个数出现一次或两次以外,其他数都出现三次,求这个数。[2行核心代码]
[本文链接] http://www.cnblogs.com/hellogiser/p/single-number-of-array-with-other-three-times.html [题目] i ...
- java将int类型的变量转化成String类型的
第一种方法:String的valueOf方法,int i=5;String s=String.valueOf(i);第二种方法,直接在int后面加一个空的字符串,因为在java里面,默认任务int类型 ...
- java里int类型转byte类型
今天在做书上的一个例子的时候, 要使用byte类型,首先我很直接的就写到了byte b = 0XAA, 结果报错, 说从int转换到byte可能会有损失. 我当时就很奇怪, 为什么会出现这种情况呢? ...
- java 判断int类型为空
int id = 10; if("0".equals(String.valueOf(id)) || "null".equals(String.valueOf(i ...
- java 13-3 int类型的包装包Integer
1.Integer的概述 需求1:把100这个数据的二进制,八进制,十六进制计算出来 需求2:判断一个数据是否是int范围内的. 首先你得知道int的范围是多大? 为了对基本数据类型进行更多的操作, ...
- Android NDK 开发(四)java传递数据到C【转】
转载请注明出处:http://blog.csdn.net/allen315410/article/details/41845701 前面几篇文章介绍了Android NDK开发的简单概念.常见错误及处 ...
- [改善Java代码]避开基本类型数组转换列表陷阱
开发中经常用到Arrays和Collections这两个工具类. 在数组和列表之间进行切换.非常方便.但是也会遇到一些问题. 看代码: import java.util.Arrays; import ...
随机推荐
- Fiddler 抓取手机APP数据包
Fiddler是一个调试代理,下载地址http://www.telerik.com/download/fiddler 下载安装运行后,查出运行机器的IP,手机连接同一网域内的WIFI,手机WIFI连接 ...
- 【转】Key/Value之王Memcached初探:一、掀起Memcached的盖头来
一.Memcached是何方神圣? 在数据驱动的Web开发中,经常要重复从数据库中取出相同的数据,这种重复极大的增加了数据库负载.缓存是解决这个问题的好办法.但是ASP.NET中的HttpRuntim ...
- Clr编写Insert Triggr
在CLR编写一个插入娄据的触发器. 这个触发器是当对表插入数据时,即时把刚才插入的数据显示出来: 可复制代码: public static void tri_RetrieveJustInsertedD ...
- 【FTP】在自己的电脑上建立FTP服务器
<1> 添加新用户: “计算机”点击右键 “管理”得到: 点击“本地用户和组”,点击“用户”: 右键 “新用户”: 设定用户名与密码,这是以后连FTP服务器时用的登录用户名与密码. < ...
- (二)NetHelper
[转]http://blog.csdn.net/dingxiaowei2013/article/details/8113454 using System; using System.Text; usi ...
- asp.net中Ajax控件的用途(一)
1,UpdatePanel控件,用户更新部分内容,示例 放入一个Label和一个Button,单击按钮,label显示当前时间. 2,ScriptManagerProxy控件,每个页面只能有一个Scr ...
- EditText html 出现提示 This text field does not specify an inputType or a hint
1 <EditText 2 android:layout_width="fill_parent" 3 android:layout_height="wrap_c ...
- C# 使用memcache(memcache安装)
1.下载memcache. 2.安装memcache. 3.安装好后,打开任务管理器就能看到memcache服务了. 4 .memcache基本命令.
- Extjs 回车查询
listeners: { afterRender: function (thisForm, options) { this.keyNav = Ext.create('Ext.util.KeyNav', ...
- Exception raised during rendering: java.lang.System.arraycopy([CI[CII)V
最近下载一个新版本的adt-bundle,Android API是20. 把Plain Text控件往布局上面拖时,发现拖不上去,出现了下面的错误: Exception raised during r ...