android Jin String

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

android jin 数组

  1. #include <stdio.h>
  2. #include <jni.h>
  3. jint Java_sony_MedicalRecordDemo_MainActivity_decryptionSuccess(JNIEnv* env, jobject thiz,jintArray Attr)
  4. {
  5. jint* arr;
  6. jint length;
  7. arr = (*env)->GetIntArrayElements(env,Attr,NULL);
  8. length = (*env)->GetArrayLength(env,Attr);
  9. return arr[0];
  10. }