• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Android_JNI_GetEnv函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Android_JNI_GetEnv函数的典型用法代码示例。如果您正苦于以下问题:C++ Android_JNI_GetEnv函数的具体用法?C++ Android_JNI_GetEnv怎么用?C++ Android_JNI_GetEnv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Android_JNI_GetEnv函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Android_JNI_SetActivityTitle

extern "C" void Android_JNI_SetActivityTitle(const char *title)
{
    jmethodID mid;
    JNIEnv *mEnv = Android_JNI_GetEnv();
    mid = mEnv->GetStaticMethodID(mActivityClass,"setActivityTitle","(Ljava/lang/String;)V");
    if (mid) {
        jstring jtitle = reinterpret_cast<jstring>(mEnv->NewStringUTF(title));
        mEnv->CallStaticVoidMethod(mActivityClass, mid, jtitle);
        mEnv->DeleteLocalRef(jtitle);
    }
}
开发者ID:mozeal,项目名称:SDL2,代码行数:11,代码来源:SDL_android.cpp


示例17: Android_JNI_GetEnv

ANativeWindow *Android_JNI_GetNativeWindow(void) {
	ANativeWindow *anw;
	jobject s;
	JNIEnv *env = Android_JNI_GetEnv();

	s = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetNativeSurface);
	anw = ANativeWindow_fromSurface(env, s);
	(*env)->DeleteLocalRef(env, s);

	return anw;
}
开发者ID:angjminer,项目名称:godot,代码行数:11,代码来源:power_android.cpp


示例18: Android_JNI_CloseAudioDevice

extern "C" void Android_JNI_CloseAudioDevice()
{
    JNIEnv *env = Android_JNI_GetEnv();

    env->CallStaticVoidMethod(mActivityClass, midAudioQuit);

    if (audioBuffer) {
        env->DeleteGlobalRef(audioBuffer);
        audioBuffer = NULL;
        audioBufferPinned = NULL;
    }
}
开发者ID:mhernando,项目名称:SDL2,代码行数:12,代码来源:SDL_android.cpp


示例19: scoreloop_submit_score

void scoreloop_submit_score(unsigned int scoreMode, unsigned int scoreValue)
{
    JNIEnv* env = Android_JNI_GetEnv();
    if (!env)
    {
        return;
    }
    jclass mActivityClass = (*env)->FindClass(env, "com/moonlite/tuxracer/GameActivity");
    jmethodID mid = (*env)->GetStaticMethodID(env, mActivityClass, "submitScore", "(II)Z");
    if (!mid)
    {
        return;
    }
    if (!(*env)->CallStaticBooleanMethod(env, mActivityClass, mid, (int)scoreMode, (int)scoreValue))
    {
        jstring j_title=(*env)->NewStringUTF(env, ALIAS_PROMPT_TITLE);
        jstring j_message=(*env)->NewStringUTF(env, ALIAS_PROMPT_MESSAGE);
        if (!getparam_should_prompt_alias())
        {
            return;
        }
        stored_score_mode=(int)scoreMode;
        stored_score_value=(int)scoreValue;
        env = Android_JNI_GetEnv();
        if (!env)
        {
            return;
        }
        mActivityClass = (*env)->FindClass(env, "com/moonlite/tuxracer/GameActivity");
        mid = (*env)->GetStaticMethodID(env, mActivityClass, "promptForAlias", "(II)V");
        if (!mid)
        {
            return;
        }
        (*env)->CallStaticVoidMethod(env, mActivityClass, mid, (int)scoreMode, (int)scoreValue);
        (*env)->DeleteLocalRef(env, j_title);
        (*env)->DeleteLocalRef(env, j_message);
    }
	return;
}
开发者ID:nopoe,项目名称:TuxRacer-SDL2,代码行数:40,代码来源:scoreboard.c


示例20: Android_JNI_FileRead

extern "C" size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer,
        size_t size, size_t maxnum)
{
    LocalReferenceHolder refs(__FUNCTION__);

    if (ctx->hidden.androidio.assetFileDescriptorRef) {
        size_t bytesMax = size * maxnum;
        if (ctx->hidden.androidio.size != -1 /*UNKNOWN_LENGTH*/ && ctx->hidden.androidio.position + bytesMax > ctx->hidden.androidio.size) {
            bytesMax = ctx->hidden.androidio.size - ctx->hidden.androidio.position;
        }
        size_t result = read(ctx->hidden.androidio.fd, buffer, bytesMax );
        if (result > 0) {
            ctx->hidden.androidio.position += result;
            return result / size;
        }
        return 0;
    } else {
        jlong bytesRemaining = (jlong) (size * maxnum);
        jlong bytesMax = (jlong) (ctx->hidden.androidio.size -  ctx->hidden.androidio.position);
        int bytesRead = 0;

        /* Don't read more bytes than those that remain in the file, otherwise we get an exception */
        if (bytesRemaining >  bytesMax) bytesRemaining = bytesMax;

        JNIEnv *mEnv = Android_JNI_GetEnv();
        if (!refs.init(mEnv)) {
            return -1;
        }

        jobject readableByteChannel = (jobject)ctx->hidden.androidio.readableByteChannelRef;
        jmethodID readMethod = (jmethodID)ctx->hidden.androidio.readMethod;
        jobject byteBuffer = mEnv->NewDirectByteBuffer(buffer, bytesRemaining);

        while (bytesRemaining > 0) {
            // result = readableByteChannel.read(...);
            int result = mEnv->CallIntMethod(readableByteChannel, readMethod, byteBuffer);

            if (Android_JNI_ExceptionOccurred()) {
                return 0;
            }

            if (result < 0) {
                break;
            }

            bytesRemaining -= result;
            bytesRead += result;
            ctx->hidden.androidio.position += result;
        }
        return bytesRead / size;
    }
}
开发者ID:mozeal,项目名称:SDL2,代码行数:52,代码来源:SDL_android.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Angle函数代码示例发布时间:2022-05-30
下一篇:
C++ AndroidBitmap_unlockPixels函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap