当前位置: 首页>>代码示例>>C++>>正文


C++ Android_JNI_GetEnv函数代码示例

本文整理汇总了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;
}
开发者ID:iar-wain,项目名称:orx-test,代码行数:34,代码来源:orxAndroidSupport.cpp

示例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);
}
开发者ID:cdlewis,项目名称:mupen64plus-ae,代码行数:26,代码来源:ae_imports.cpp

示例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;
}
开发者ID:Deraen,项目名称:ohj2710,代码行数:35,代码来源:SDL_android.cpp

示例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;
}
开发者ID:mozeal,项目名称:SDL2,代码行数:33,代码来源:SDL_android.cpp

示例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;
}
开发者ID:tux4kids,项目名称:Tuxpaint-Android,代码行数:33,代码来源:android_print.c

示例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);
}
开发者ID:iar-wain,项目名称:orx-test,代码行数:7,代码来源:orxAndroidSupport.cpp

示例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);
}
开发者ID:agangzz,项目名称:timidity-ae,代码行数:8,代码来源:helper.c

示例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);
}
开发者ID:agangzz,项目名称:timidity-ae,代码行数:8,代码来源:helper.c

示例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);
}
开发者ID:agangzz,项目名称:timidity-ae,代码行数:9,代码来源:helper.c

示例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;
}
开发者ID:agangzz,项目名称:timidity-ae,代码行数:9,代码来源:helper.c

示例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;
    }
}
开发者ID:Deraen,项目名称:ohj2710,代码行数:9,代码来源:SDL_android.cpp

示例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);
    }
}
开发者ID:Dyndrilliac,项目名称:project64,代码行数:9,代码来源:JavaBridge.cpp

示例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);
    }
}
开发者ID:JunielKatarn,项目名称:Project64CI,代码行数:9,代码来源:JavaBridge.cpp

示例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;
}
开发者ID:CrypticGator,项目名称:hackterm,代码行数:56,代码来源:SDL_android.cpp

示例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);
}
开发者ID:Derek-OBrien,项目名称:DsdlEngine,代码行数:11,代码来源:SDL_androidtouch.c


注:本文中的Android_JNI_GetEnv函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。