android Jin String
public class MainActivity extends AppCompatActivity {
static{
System.loadLibrary("myndk");
}
private TextView textView;
public native String getStr(String[] oa);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView)findViewById(R.id.text);
String[] oa={"你呀","我呀"};
textView.setText(getStr(oa));
}
————————————————
版权声明:本文为CSDN博主「night_iv」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/night_iv/article/details/76071686
//C++ (这里是支持C++11的)
#include <iostream>
#include <string>
JNIEXPORT jstring JNICALL
Java_com_myndk_MainActivity_getStr(JNIEnv *env, jobject instance,jobjectArray oa)
{
jsize size = env->GetArrayLength(oa);
for(int i=0;i<size;i++)
{
jstring obj = (jstring)env->GetObjectArrayElement(oa,i);
std::string sstr = (std::string)env->GetStringUTFChars(obj,NULL);//得到字符串
}
std::string str="NDK";
return env->NewStringUTF(str.data());
————————————————
版权声明:本文为CSDN博主「night_iv」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/night_iv/article/details/76071686
android jin 数组
#include <stdio.h>
#include <jni.h>
jint Java_sony_MedicalRecordDemo_MainActivity_decryptionSuccess(JNIEnv* env, jobject thiz,jintArray Attr)
{
jint* arr;
jint length;
arr = (*env)->GetIntArrayElements(env,Attr,NULL);
length = (*env)->GetArrayLength(env,Attr);
return arr[0];
}