本文整理匯總了C++中Android_JNI_GetEnv函數的典型用法代碼示例。如果您正苦於以下問題:C++ Android_JNI_GetEnv函數的具體用法?C++ Android_JNI_GetEnv怎麽用?C++ Android_JNI_GetEnv使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Android_JNI_GetEnv函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: orxAndroid_GetInternalStoragePath
extern "C" const char * orxAndroid_GetInternalStoragePath()
{
if (!sstAndroid.zAndroidInternalFilesPath)
{
jmethodID mid;
jobject fileObject;
jstring pathString;
const char *path;
jobject jActivity;
JNIEnv *env = Android_JNI_GetEnv();
mid = env->GetMethodID(env->GetObjectClass(sstAndroid.mActivity), "getFilesDir", "()Ljava/io/File;");
fileObject = env->CallObjectMethod(sstAndroid.mActivity, mid);
if (!fileObject)
{
LOGE("Couldn't get internal directory");
return NULL;
}
// path = fileObject.getAbsolutePath();
mid = env->GetMethodID(env->GetObjectClass(fileObject), "getAbsolutePath", "()Ljava/lang/String;");
pathString = (jstring)env->CallObjectMethod(fileObject, mid);
env->DeleteLocalRef(fileObject);
path = env->GetStringUTFChars(pathString, NULL);
sstAndroid.zAndroidInternalFilesPath = strdup(path);
env->ReleaseStringUTFChars(pathString, path);
env->DeleteLocalRef(pathString);
}
return sstAndroid.zAndroidInternalFilesPath;
}
示例2: Android_JNI_StateCallback
extern DECLSPEC void Android_JNI_StateCallback(void* context, m64p_core_param paramChanged, int newValue)
{
/*----ParamChanged-----------------
* --------NewValue--------
* M64CORE_EMU_STATE 1
* M64EMU_STOPPED 1
* M64EMU_RUNNING 2
* M64EMU_PAUSED 3
* M64CORE_VIDEO_MODE 2
* M64CORE_SAVESTATE_SLOT 3
* M64CORE_SPEED_FACTOR 4
* M64CORE_SPEED_LIMITER 5
* M64CORE_VIDEO_SIZE 6
* M64CORE_AUDIO_VOLUME 7
* M64CORE_AUDIO_MUTE 8
* M64CORE_INPUT_GAMESHARK 9
* M64CORE_STATE_LOADCOMPLETE 10
* (successful) 1
* (unsuccessful) 0
* M64CORE_STATE_SAVECOMPLETE 11
* (successful) 1
* (unsuccessful) 0
*/
JNIEnv *env = Android_JNI_GetEnv();
env->CallStaticVoidMethod(mActivityClass, midStateCallback, (int) paramChanged, newValue);
}
示例3: Android_JNI_FileClose
static int Android_JNI_FileClose(SDL_RWops* ctx, bool release)
{
LocalReferenceHolder refs(__FUNCTION__);
int result = 0;
JNIEnv *mEnv = Android_JNI_GetEnv();
if (!refs.init(mEnv)) {
SDL_SetError("Failed to allocate enough JVM local references");
return -1;
}
if (ctx) {
if (release) {
mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.fileNameRef);
}
jobject inputStream = (jobject)ctx->hidden.androidio.inputStreamRef;
// inputStream.close();
jmethodID mid = mEnv->GetMethodID(mEnv->GetObjectClass(inputStream),
"close", "()V");
mEnv->CallVoidMethod(inputStream, mid);
mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.inputStreamRef);
mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.readableByteChannelRef);
if (Android_JNI_ExceptionOccurred()) {
result = -1;
}
if (release) {
SDL_FreeRW(ctx);
}
}
return result;
}
示例4: Android_JNI_CreateContext
extern "C" SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion,
int red, int green, int blue, int alpha,
int buffer, int depth, int stencil,
int buffers, int samples)
{
JNIEnv *env = Android_JNI_GetEnv();
jint attribs[] = {
EGL_RED_SIZE, red,
EGL_GREEN_SIZE, green,
EGL_BLUE_SIZE, blue,
EGL_ALPHA_SIZE, alpha,
EGL_BUFFER_SIZE, buffer,
EGL_DEPTH_SIZE, depth,
EGL_STENCIL_SIZE, stencil,
EGL_SAMPLE_BUFFERS, buffers,
EGL_SAMPLES, samples,
EGL_RENDERABLE_TYPE, (majorVersion == 1 ? EGL_OPENGL_ES_BIT : EGL_OPENGL_ES2_BIT),
EGL_NONE
};
int len = SDL_arraysize(attribs);
jintArray array;
array = env->NewIntArray(len);
env->SetIntArrayRegion(array, 0, len, attribs);
jboolean success = env->CallStaticBooleanMethod(mActivityClass, midCreateGLContext, majorVersion, minorVersion, array);
env->DeleteLocalRef(array);
return success ? SDL_TRUE : SDL_FALSE;
}
示例5: Android_JNI_GetEnv
// This function is based on
// (1) convert surface to Java BitMap object
// (2) call Java PrintHelper to do print job.
const char *SurfacePrint(SDL_Surface *surface)
{
JNIEnv *mEnv = Android_JNI_GetEnv();
jclass mBitmapClass = (*mEnv)->FindClass(mEnv, "android/graphics/Bitmap");
jmethodID mCreateMethod = (*mEnv)->GetStaticMethodID(mEnv, mBitmapClass, "createBitmap", "([IIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;");
jintArray mSurfaceArray = (*mEnv)->NewIntArray(mEnv, surface->w * surface->h);
(*mEnv)->SetIntArrayRegion(mEnv,mSurfaceArray, 0, surface->w * surface->h, surface->pixels);
jclass mConfigClass = (*mEnv)->FindClass(mEnv, "android/graphics/Bitmap$Config");
jfieldID mConfigField = (*mEnv)->GetStaticFieldID(mEnv, mConfigClass , "ARGB_8888", "Landroid/graphics/Bitmap$Config;");
jobject mConfig = (*mEnv)->GetStaticObjectField(mEnv, mConfigClass, mConfigField);
jobject mBitMap = (*mEnv)->CallStaticObjectMethod(mEnv, mBitmapClass, mCreateMethod, mSurfaceArray, surface->w, surface->h, mConfig);
jobject mContext = (jobject)SDL_AndroidGetActivity();
jclass mPrintClass = (*mEnv)->FindClass(mEnv, "android/support/v4/print/PrintHelper");
// sometimes android v4 support library may be not ready
if (mPrintClass == NULL)
return "There is no android v4 support library.";
jmethodID mInitMethod = (*mEnv)->GetMethodID(mEnv, mPrintClass, "<init>", "(Landroid/content/Context;)V");
jobject mPrint = (*mEnv)->NewObject(mEnv, mPrintClass, mInitMethod, mContext);
jmethodID mPrintMethod = (*mEnv)->GetMethodID(mEnv, mPrintClass, "printBitmap", "(Ljava/lang/String;Landroid/graphics/Bitmap;)V");
jstring mString = (*mEnv)->NewStringUTF(mEnv, "TuxPaint");
(*mEnv)->CallVoidMethod(mEnv, mPrint, mPrintMethod, mString, mBitMap);
// clean up
(*mEnv)->DeleteLocalRef(mEnv, mSurfaceArray);
(*mEnv)->DeleteLocalRef(mEnv, mConfig);
(*mEnv)->DeleteLocalRef(mEnv, mPrint);
(*mEnv)->DeleteLocalRef(mEnv, mString);
return NULL;
}
示例6: orxAndroid_JNI_GetDeviceIds
extern "C" void orxAndroid_JNI_GetDeviceIds(orxS32 deviceIds[4])
{
JNIEnv *env = Android_JNI_GetEnv();
jintArray retval = (jintArray) env->CallObjectMethod(sstAndroid.mActivity, sstAndroid.midGetDeviceIds);
env->GetIntArrayRegion(retval, 0, 4, (jint*) &deviceIds[0]);
env->DeleteLocalRef(retval);
}
示例7: setCurrLyric
void setCurrLyric(char* lyric)
{
JNIEnv* theGoodEnv = Android_JNI_GetEnv();
jbyteArray byteArr = (*theGoodEnv)->NewByteArray(theGoodEnv, 300);
(*theGoodEnv)->SetByteArrayRegion(theGoodEnv, byteArr , 0, 300, (jbyte *)lyric);
(*theGoodEnv)->CallStaticVoidMethod(theGoodEnv, pushClazz, pushLyricId, byteArr, 300);
(*theGoodEnv)->DeleteLocalRef(theGoodEnv, byteArr);
}
示例8: flushIt
void flushIt()
{
JNIEnv* theGoodEnv = Android_JNI_GetEnv();
//jclass clazz = (*theGoodEnv)->FindClass(theGoodEnv, "com/xperia64/timidityae/JNIHandler");
//jmethodID buffit = (*theGoodEnv)->GetStaticMethodID(theGoodEnv, pushClazz, "flushIt", "()V");
(*theGoodEnv)->CallStaticIntMethod(theGoodEnv, pushClazz, flushId);
//(*theGoodEnv)->DeleteLocalRef(theGoodEnv, clazz);
}
示例9: controller
void controller(int aa)
{
JNIEnv* theGoodEnv = Android_JNI_GetEnv();
//jclass clazz = (*theGoodEnv)->FindClass(theGoodEnv, "com/xperia64/timidityae/JNIHandler");
//jclass cls = (*envelope)->GetObjectClass(envelope, mine);
//jmethodID buffit = (*theGoodEnv)->GetStaticMethodID(theGoodEnv, clazz, "controlMe", "(I)V");
(*theGoodEnv)->CallStaticVoidMethod(theGoodEnv, pushClazz, controlId, aa);
//(*theGoodEnv)->DeleteLocalRef(theGoodEnv, clazz);
}
示例10: getBuffer
int getBuffer()
{
JNIEnv* theGoodEnv = Android_JNI_GetEnv();
//jclass clazz = (*theGoodEnv)->FindClass(theGoodEnv, "com/xperia64/timidityae/JNIHandler");
//jmethodID buffit = (*theGoodEnv)->GetStaticMethodID(theGoodEnv, clazz, "bufferSize", "()I");
int r = (int)(*theGoodEnv)->CallStaticIntMethod(theGoodEnv, pushClazz, buffId);
//(*theGoodEnv)->DeleteLocalRef(theGoodEnv, clazz);
return r;
}
示例11: Android_JNI_CreateContext
extern "C" SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion)
{
JNIEnv *mEnv = Android_JNI_GetEnv();
if (mEnv->CallStaticBooleanMethod(mActivityClass, midCreateGLContext, majorVersion, minorVersion)) {
return SDL_TRUE;
} else {
return SDL_FALSE;
}
}
示例12: Android_JNI_GetEnv
void JavaBridge::EmulationStopped(void)
{
JNIEnv *env = Android_JNI_GetEnv();
if (g_Activity != NULL && env != NULL)
{
jmethodID midEmulationStopped = env->GetStaticMethodID(m_NotifierClass, "EmulationStopped", "(Landroid/app/Activity;)V");
env->CallStaticVoidMethod(m_NotifierClass, midEmulationStopped, g_Activity);
}
}
示例13: Android_JNI_GetEnv
void JavaBridge::RecentRomsUpdated(void)
{
JNIEnv *env = Android_JNI_GetEnv();
if (env)
{
jmethodID midRRecentRomsUpdated = env->GetStaticMethodID(m_GalleryActivityClass, "RecentRomsUpdated", "()V");
env->CallStaticVoidMethod(m_GalleryActivityClass, midRRecentRomsUpdated);
}
}
示例14: Android_JNI_OpenAudioDevice
extern "C" int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames)
{
int audioBufferFrames;
int status;
JNIEnv *env = Android_JNI_GetEnv();
if (!env) {
LOGE("callback_handler: failed to attach current thread");
}
Android_JNI_SetupThread();
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device");
audioBuffer16Bit = is16Bit;
audioBufferStereo = channelCount > 1;
env->CallStaticObjectMethod(mActivityClass, midAudioInit, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames);
/* Allocating the audio buffer from the Java side and passing it as the return value for audioInit no longer works on
* Android >= 4.2 due to a "stale global reference" error. So now we allocate this buffer directly from this side. */
if (is16Bit) {
jshortArray audioBufferLocal = env->NewShortArray(desiredBufferFrames * (audioBufferStereo ? 2 : 1));
if (audioBufferLocal) {
audioBuffer = env->NewGlobalRef(audioBufferLocal);
env->DeleteLocalRef(audioBufferLocal);
}
}
else {
jbyteArray audioBufferLocal = env->NewByteArray(desiredBufferFrames * (audioBufferStereo ? 2 : 1));
if (audioBufferLocal) {
audioBuffer = env->NewGlobalRef(audioBufferLocal);
env->DeleteLocalRef(audioBufferLocal);
}
}
if (audioBuffer == NULL) {
__android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: could not allocate an audio buffer!");
return 0;
}
jboolean isCopy = JNI_FALSE;
if (audioBuffer16Bit) {
audioBufferPinned = env->GetShortArrayElements((jshortArray)audioBuffer, &isCopy);
audioBufferFrames = env->GetArrayLength((jshortArray)audioBuffer);
} else {
audioBufferPinned = env->GetByteArrayElements((jbyteArray)audioBuffer, &isCopy);
audioBufferFrames = env->GetArrayLength((jbyteArray)audioBuffer);
}
if (audioBufferStereo) {
audioBufferFrames /= 2;
}
return audioBufferFrames;
}
示例15: SeparateEventsHintWatcher
static void
SeparateEventsHintWatcher(void *userdata, const char *name,
const char *oldValue, const char *newValue)
{
jclass mActivityClass = Android_JNI_GetActivityClass();
JNIEnv *env = Android_JNI_GetEnv();
jfieldID fid = (*env)->GetStaticFieldID(env, mActivityClass, "mSeparateMouseAndTouch", "Z");
separate_mouse_and_touch = (newValue && (SDL_strcmp(newValue, "1") == 0));
(*env)->SetStaticBooleanField(env, mActivityClass, fid, separate_mouse_and_touch ? JNI_TRUE : JNI_FALSE);
}