Chinaunix首页 | 论坛 | 博客
  • 博客访问: 463765
  • 博文数量: 145
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1060
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-22 11:52
个人简介

专注计算机技术: Linux Android 云计算 虚拟化 网络

文章分类

全部博文(145)

文章存档

2016年(3)

2015年(21)

2014年(75)

2013年(46)

我的朋友

分类: Android平台

2014-11-06 05:52:11

First, don't use AndroidRuntime::getJNIEnv(). That's not part of the NDK API. You should be using the JNI "GetEnv" function instead.

Second, GetEnv returns NULL if the current thread is not attached to the VM. (Remember, JNIEnv is thread-specific.) If you created the thread yourself, you will need to use the JNI AttachCurrentThread function to attach it.

Both of these require a JavaVM pointer. There's only one of these per process, so you can get it during JNI_OnLoad or a setup call from your program (GetJavaVM function) when you have a JNIEnv passed in.

If you haven't yet, read through the JNI Tips page (which includes references to some comprehensive JNI docs).

 

阅读(1434) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~