本文整理汇总了C++中JNIEnv::CallBooleanMethod方法的典型用法代码示例。如果您正苦于以下问题:C++ JNIEnv::CallBooleanMethod方法的具体用法?C++ JNIEnv::CallBooleanMethod怎么用?C++ JNIEnv::CallBooleanMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JNIEnv
的用法示例。
在下文中一共展示了JNIEnv::CallBooleanMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: displayKeyboard
// Display the android virtual keyboard.
static void displayKeyboard(android_app* state, bool show)
{
// The following functions is supposed to show / hide functins from a native activity.. but currently do not work.
// ANativeActivity_showSoftInput(state->activity, ANATIVEACTIVITY_SHOW_SOFT_INPUT_IMPLICIT);
// ANativeActivity_hideSoftInput(state->activity, ANATIVEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY);
// Show or hide the keyboard by calling the appropriate Java method through JNI instead.
jint result;
jint flags = 0;
JavaVM* jvm = state->activity->vm;
JNIEnv* env;
jvm->GetEnv((void **)&env, JNI_VERSION_1_6);
jvm->AttachCurrentThread(&env, NULL);
if (result == JNI_ERR)
{
return;
}
// Retrieves NativeActivity.
jobject lNativeActivity = state->activity->clazz;
jclass ClassNativeActivity = env->GetObjectClass(lNativeActivity);
// Retrieves Context.INPUT_METHOD_SERVICE.
jclass ClassContext = env->FindClass("android/content/Context");
jfieldID FieldINPUT_METHOD_SERVICE = env->GetStaticFieldID(ClassContext, "INPUT_METHOD_SERVICE", "Ljava/lang/String;");
jobject INPUT_METHOD_SERVICE = env->GetStaticObjectField(ClassContext, FieldINPUT_METHOD_SERVICE);
// Runs getSystemService(Context.INPUT_METHOD_SERVICE).
jclass ClassInputMethodManager = env->FindClass("android/view/inputmethod/InputMethodManager");
jmethodID MethodGetSystemService = env->GetMethodID(ClassNativeActivity, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;");
jobject lInputMethodManager = env->CallObjectMethod(lNativeActivity, MethodGetSystemService, INPUT_METHOD_SERVICE);
// Runs getWindow().getDecorView().
jmethodID MethodGetWindow = env->GetMethodID(ClassNativeActivity, "getWindow", "()Landroid/view/Window;");
jobject lWindow = env->CallObjectMethod(lNativeActivity, MethodGetWindow);
jclass ClassWindow = env->FindClass("android/view/Window");
jmethodID MethodGetDecorView = env->GetMethodID(ClassWindow, "getDecorView", "()Landroid/view/View;");
jobject lDecorView = env->CallObjectMethod(lWindow, MethodGetDecorView);
if (show)
{
// Runs lInputMethodManager.showSoftInput(...).
jmethodID MethodShowSoftInput = env->GetMethodID( ClassInputMethodManager, "showSoftInput", "(Landroid/view/View;I)Z");
jboolean result = env->CallBooleanMethod(lInputMethodManager, MethodShowSoftInput, lDecorView, flags);
}
else
{
// Runs lWindow.getViewToken()
jclass ClassView = env->FindClass("android/view/View");
jmethodID MethodGetWindowToken = env->GetMethodID(ClassView, "getWindowToken", "()Landroid/os/IBinder;");
jobject lBinder = env->CallObjectMethod(lDecorView, MethodGetWindowToken);
// lInputMethodManager.hideSoftInput(...).
jmethodID MethodHideSoftInput = env->GetMethodID(ClassInputMethodManager, "hideSoftInputFromWindow", "(Landroid/os/IBinder;I)Z");
jboolean lRes = env->CallBooleanMethod( lInputMethodManager, MethodHideSoftInput, lBinder, flags);
}
// Finished with the JVM.
jvm->DetachCurrentThread();
}
示例2: toProcessRequest
void JniManager::toProcessRequest(jobject obj, MonoObject* processRequest)
{
JNIEnv* env = getEnv();
MonoDomain* monoDomain = getMonoDomain();
string c_assemblyName = typeConverter->convertToC<string>(env, env->CallObjectMethod(obj, getAssemblyName, "()Ljava/lang/String;"));
string c_assemblyPath = typeConverter->convertToC<string>(env, env->CallObjectMethod(obj, getAssemblyPath, "()Ljava/lang/String;"));
string c_methodName = typeConverter->convertToC<string>(env, env->CallObjectMethod(obj, getMethodName, "()Ljava/lang/String;"));
MonoString* assemblyName = mono_string_new(monoDomain, c_assemblyName.c_str());
MonoString* assemblyPath = mono_string_new(monoDomain, c_assemblyPath.c_str());
MonoString* methodName = mono_string_new(monoDomain, c_methodName.c_str());
bool fullTrust = env->CallBooleanMethod(obj, getFullTrust);
bool isSingleton = env->CallBooleanMethod(obj, getIsSingleton);
bool log = env->CallBooleanMethod(obj, getLog);
bool notifyEvents = env->CallBooleanMethod(obj, getNotifyEvents);
MonoObject* exception = NULL;
void* args[1];
args[0] = assemblyName;
mono_runtime_invoke(setAssemblyNameField, processRequest, args, &exception);
args[0] = assemblyPath;
mono_runtime_invoke(setAssemblyPathField, processRequest, args, &exception);
args[0] = methodName;
mono_runtime_invoke(setMethodNameField, processRequest, args, &exception);
args[0] = &fullTrust;
mono_runtime_invoke(setFullTrustField, processRequest, args, &exception);
args[0] = &log;
mono_runtime_invoke(setLogField, processRequest, args, &exception);
args[0] = &isSingleton;
mono_runtime_invoke(setIsSingletonField, processRequest, args, &exception);
args[0] = ¬ifyEvents;
mono_runtime_invoke(setNotifyEventsField, processRequest, args, &exception);
if (exception)
{
const char* message = mono_string_to_utf8(mono_object_to_string(exception, NULL));
throwException(message);
}
jobject javaMethodArguments = env->CallObjectMethod(obj, getMethodArguments);
setProperties(env, javaMethodArguments, addMethodArgumentsProperty, processRequest);
//request->MethodArguments = typeConverter->convertToC<Dictionary<String^, Object^>^>(env, env->CallObjectMethod(obj, getMethodArguments));
//request->InboundProperties = typeConverter->convertToC<Dictionary<String^, Object^>^>(env, env->CallObjectMethod(obj, getInboundProperties));
//request->InvocationProperties = typeConverter->convertToC<Dictionary<String^, Object^>^>(env, env->CallObjectMethod(obj, getInvocationProperties));
//request->OutboundProperties = typeConverter->convertToC<Dictionary<String^, Object^>^>(env, env->CallObjectMethod(obj, getOutboundProperties));
//request->SessionProperties = typeConverter->convertToC<Dictionary<String^, Object^>^>(env, env->CallObjectMethod(obj, getSessionProperties));
}
示例3: get_list_of_nonlinear_variables
bool Jipopt::get_list_of_nonlinear_variables(Index num_nonlin_vars,Index* pos_nonlin_vars)
{
if( using_LBFGS )
{
jintArray pos_nonlin_vars_j = env->NewIntArray(num_nonlin_vars);
if( !env->CallBooleanMethod(solver, get_list_of_nonlinear_variables_, num_nonlin_vars, pos_nonlin_vars_j) )
return false;
if( pos_nonlin_vars != NULL )
{
if( sizeof(jint) == sizeof(Index) )
{
env->GetIntArrayRegion(pos_nonlin_vars_j, 0, num_nonlin_vars, reinterpret_cast<jint*>(pos_nonlin_vars));
}
else
{
jint* tmp = new int[num_nonlin_vars];
env->GetIntArrayRegion(pos_nonlin_vars_j, 0, num_nonlin_vars, tmp);
for( int i = 0; i < num_nonlin_vars; ++i )
pos_nonlin_vars[i] = (Index)tmp[i];
delete[] tmp;
}
}
return true;
}
return false;
}
示例4: get_starting_point
bool Jipopt::get_starting_point(Index n, bool init_x, Number* x,
bool init_z, Number* z_L, Number* z_U,
Index m, bool init_lambda, Number* lambda)
{
jdoubleArray xj = this->xj;
jdoubleArray z_lj = this->mult_x_Lj;
jdoubleArray z_uj = this->mult_x_Uj;
jdoubleArray lambdaj = this->mult_gj;
if( !env->CallBooleanMethod(solver, get_starting_point_, n, init_x, xj, init_z, z_lj, z_uj, m, init_lambda, lambdaj) )
return false;
/* Copy from Java to native value */
if( init_x )
env->GetDoubleArrayRegion(xj, 0, n, x);
if( init_z )
{
env->GetDoubleArrayRegion(z_lj, 0, n, z_L);
env->GetDoubleArrayRegion(z_uj, 0, n, z_U);
}
if( init_lambda )
env->GetDoubleArrayRegion(lambdaj, 0, m, lambda);
return true;
}
示例5: get_bounds_info
bool Jipopt::get_bounds_info(Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)
{
jdoubleArray x_lj = NULL;
jdoubleArray x_uj = NULL;
jdoubleArray g_lj = NULL;
jdoubleArray g_uj = NULL;
assert(x_l != NULL);
assert(x_u != NULL);
assert(g_l != NULL);
assert(g_u != NULL);
x_lj = env->NewDoubleArray(n);
x_uj = env->NewDoubleArray(n);
g_lj = env->NewDoubleArray(m);
g_uj = env->NewDoubleArray(m);
if( !env->CallBooleanMethod(solver, get_bounds_info_, n, x_lj, x_uj, m, g_lj, g_uj) )
return false;
// Copy from Java to native value
env->GetDoubleArrayRegion(x_lj, 0, n, x_l);
env->GetDoubleArrayRegion(x_uj, 0, n, x_u);
env->GetDoubleArrayRegion(g_lj, 0, m, g_l);
env->GetDoubleArrayRegion(g_uj, 0, m, g_u);
return true;
}
示例6: getLoopState
//------------------------------------------------------------
ofLoopType ofxAndroidVideoPlayer::getLoopState() const {
if(!javaVideoPlayer){
ofLogError("ofxAndroidVideoPlayer") << "getLoopState(): java VideoPlayer not loaded";
return OF_LOOP_NONE;
}
JNIEnv *env = ofGetJNIEnv();
if (!env) {
ofLogError("ofxAndroidVideoPlayer") << "getLoopState(): couldn't get environment using GetEnv()";
return OF_LOOP_NONE;
}
jmethodID javaGetLoopStateMethod = env->GetMethodID(javaClass,"getLoopState","()Z");
if(!javaGetLoopStateMethod){
ofLogError("ofxAndroidVideoPlayer") << "getLoopState(): couldn't get java GetLoopState for VideoPlayer";
return OF_LOOP_NONE;
}
bool loopState = env->CallBooleanMethod(javaVideoPlayer,javaGetLoopStateMethod);
if (loopState) {
return OF_LOOP_NORMAL;
} else {
return OF_LOOP_NONE;
}
};
示例7: HasInstanceCallback
bool JSFunction::HasInstanceCallback(JSContextRef ctx, JSObjectRef constructor,
JSValueRef possibleInstance, JSValueRef* exception)
{
JNIEnv *env;
int getEnvStat = jvm->GetEnv((void**)&env, JNI_VERSION_1_6);
if (getEnvStat == JNI_EDETACHED) {
jvm->AttachCurrentThread(&env, NULL);
}
jclass cls = env->GetObjectClass(thiz);
jmethodID mid;
do {
mid = env->GetMethodID(cls,"hasInstanceCallback","(JJJJ)Z");
if (!env->ExceptionCheck()) break;
env->ExceptionClear();
jclass super = env->GetSuperclass(cls);
env->DeleteLocalRef(cls);
if (super == NULL || env->ExceptionCheck()) {
if (super != NULL) env->DeleteLocalRef(super);
jvm->DetachCurrentThread();
return NULL;
}
cls = super;
} while (true);
env->DeleteLocalRef(cls);
bool ret = env->CallBooleanMethod(thiz, mid, (jlong)ctx, (jlong)constructor,
(jlong)possibleInstance, (jlong)exception);
if (getEnvStat == JNI_EDETACHED) {
jvm->DetachCurrentThread();
}
return ret;
}
示例8: copy
bool HDFSAccessor::copy(char* srcPath, char* destPath)
{
bool isNewEnv = false;
JNIEnv* env = JVMState::instance()->getEnv(&isNewEnv);
if (m_wfxPairObj != NULL)
{
jstring srcPathStr = env->NewStringUTF(srcPath);
jstring destPathStr = env->NewStringUTF(destPath);
jboolean retVal = env->CallBooleanMethod(m_wfxPairObj, s_WfxPairMetIdCopyPath, srcPathStr, destPathStr);
if (!JVMState::instance()->exceptionExists(env))
{
env->DeleteLocalRef(srcPathStr);
env->DeleteLocalRef(destPathStr);
if (isNewEnv)
{
JVMState::instance()->releaseEnv();
}
return retVal == JNI_TRUE;
} else
{
env->DeleteLocalRef(srcPathStr);
env->DeleteLocalRef(destPathStr);
}
}
if (isNewEnv)
{
JVMState::instance()->releaseEnv();
}
return false;
}
示例9: mkdir
bool HDFSAccessor::mkdir(char* path)
{
bool isNewEnv = false;
JNIEnv* env = JVMState::instance()->getEnv(&isNewEnv);
if (m_wfxPairObj != NULL)
{
jstring pathStr = env->NewStringUTF(path);
jboolean retVal = env->CallBooleanMethod(m_wfxPairObj, s_WfxPairMetIdMkDir, pathStr);
if (!JVMState::instance()->exceptionExists(env))
{
env->DeleteLocalRef(pathStr);
if (isNewEnv)
{
JVMState::instance()->releaseEnv();
}
return retVal == JNI_TRUE;
} else
{
env->DeleteLocalRef(pathStr);
}
}
if (isNewEnv)
{
JVMState::instance()->releaseEnv();
}
return false;
}
示例10: IsDirectory
bool IsDirectory(const tstring& sPath)
{
// Check first to see if it's in the assets folder.
JNIEnv* env = (JNIEnv*)SDL_AndroidGetJNIEnv();
jobject activity = (jobject)SDL_AndroidGetActivity();
jclass activity_class = env->GetObjectClass(activity);
jmethodID activity_class_assetIsDirectory = env->GetMethodID(activity_class, "assetIsDirectory", "(Ljava/lang/String;)Z");
jstring assetIsDirectory_sFile = env->NewStringUTF(sPath.c_str());
jboolean assetIsDirectory_result = env->CallBooleanMethod(activity, activity_class_assetIsDirectory, assetIsDirectory_sFile); // activity.assetIsDirectory(file);
bool bIsDirectory = assetIsDirectory_result;
env->DeleteLocalRef(assetIsDirectory_sFile);
if (bIsDirectory)
return true;
struct stat stFileInfo;
bool blnReturn;
int intStat;
// Attempt to get the file attributes
intStat = stat(sPath.c_str(), &stFileInfo);
if(intStat == 0 && S_ISDIR(stFileInfo.st_mode))
return true;
else
return false;
}
示例11: Billing_IsProductPurchased
bool Billing_IsProductPurchased(const char* sku) {
JNIEnv* env = getEnv();
jclass k = env->GetObjectClass(jBilling);
jmethodID m = env->GetMethodID(k, "isProductPurchased", "(Ljava/lang/String;)Z");
jstring jSku = env->NewStringUTF(sku);
return env->CallBooleanMethod(jBilling, m, jSku);
}
示例12: isInterrupted
int32_t
JNIHelper :: isInterrupted()
{
JNIEnv * env = this->getEnv();
if (!env)
return 0;
if (env->ExceptionCheck())
return 1; // a pending exception interrupts us
if (!mThread_class ||
!mThread_isInterrupted_mid ||
!mThread_currentThread_mid)
// this is an error if these are not set up, but we're
// going to assume no interrupt then.
return 0;
jclass cls = static_cast<jclass>(env->NewLocalRef(mThread_class));
if (!cls)
return 0;
jobject thread = env->CallStaticObjectMethod(
cls,
mThread_currentThread_mid);
env->DeleteLocalRef(cls);
if (!thread || env->ExceptionCheck())
return 1;
jboolean result = env->CallBooleanMethod(thread,
mThread_isInterrupted_mid);
env->DeleteLocalRef(thread);
if (env->ExceptionCheck())
result = true;
if (result != JNI_FALSE)
return 1;
return 0;
}
示例13: s3eNOFhasUserApprovedFeint_platform
ushort s3eNOFhasUserApprovedFeint_platform()
{
JNIEnv* env = s3eEdkJNIGetEnv();
// env->CallVoidMethod(g_Obj, g_s3eNOFhasUserApprovedFeint);
return env->CallBooleanMethod(g_Obj, g_s3eNOFhasUserApprovedFeint);
//return S3E_RESULT_SUCCESS;
}
示例14: svn_boolean_t
svn_boolean_t
OperationContext::checkTunnel(void *tunnel_baton, const char *tunnel_name)
{
JNIEnv *env = JNIUtil::getEnv();
jstring jtunnel_name = JNIUtil::makeJString(tunnel_name);
if (JNIUtil::isJavaExceptionThrown())
return false;
static jmethodID mid = 0;
if (0 == mid)
{
jclass cls = env->FindClass(JAVAHL_CLASS("/callback/TunnelAgent"));
if (JNIUtil::isJavaExceptionThrown())
return false;
mid = env->GetMethodID(cls, "checkTunnel",
"(Ljava/lang/String;)Z");
if (JNIUtil::isJavaExceptionThrown())
return false;
}
jobject jtunnelcb = jobject(tunnel_baton);
jboolean check = env->CallBooleanMethod(jtunnelcb, mid, jtunnel_name);
if (JNIUtil::isJavaExceptionThrown())
return false;
return svn_boolean_t(check);
}
示例15: invoke_javaCallback
static bool invoke_javaCallback(int msgType, const char* msgName)
{
jstring msg_name = NULL;
UnionJNIEnvToVoid uenv;
uenv.venv = NULL;
JNIEnv* env = NULL;
bool detach = false;
if (mJvm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK)
{
if (mJvm->AttachCurrentThread(&env, NULL) != JNI_OK)
{
LOGE("callback_handler: failed to attach current thread\n");
return false;
}
detach = true;
} else {
env = uenv.env;
}
msg_name = env->NewStringUTF(msgName);
bool result = env->CallBooleanMethod(mjavaApp, method_javaCallback, msgType, msg_name);
env->DeleteLocalRef(msg_name);
if (detach)
{
if (mJvm->DetachCurrentThread() != JNI_OK)
{
LOGE("callback_handler: failed to detach current thread\n");
}
}
return result;
}