本文整理汇总了C++中JNIEnv::CallBooleanMethodA方法的典型用法代码示例。如果您正苦于以下问题:C++ JNIEnv::CallBooleanMethodA方法的具体用法?C++ JNIEnv::CallBooleanMethodA怎么用?C++ JNIEnv::CallBooleanMethodA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JNIEnv
的用法示例。
在下文中一共展示了JNIEnv::CallBooleanMethodA方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CallMember
value CallMember(jobject inObject, value inArgs)
{
JNIEnv *env = GetEnv();
jvalue jargs[MAX];
if (!HaxeToJNIArgs(env,inArgs,jargs))
{
CleanStringArgs();
ELOG("CallMember - bad argument list");
return alloc_null();
}
value result = 0;
switch(mReturn)
{
case jniVoid:
result = alloc_null();
env->CallVoidMethodA(inObject, mMethod, jargs);
break;
case jniObject:
result = JObjectToHaxe(env->CallObjectMethodA(inObject,mMethod, jargs));
break;
case jniObjectString:
result = JStringToHaxe(env,env->CallObjectMethodA(inObject, mMethod, jargs));
break;
case jniObjectArray:
result = JArrayToHaxe(env->CallObjectMethodA(inObject, mMethod, jargs));
break;
case jniBoolean:
result = alloc_bool(env->CallBooleanMethodA(inObject, mMethod, jargs));
break;
case jniByte:
result = alloc_int(env->CallByteMethodA(inObject, mMethod, jargs));
break;
case jniChar:
result = alloc_int(env->CallCharMethodA(inObject, mMethod, jargs));
break;
case jniShort:
result = alloc_int(env->CallShortMethodA(inObject, mMethod, jargs));
break;
case jniInt:
result = alloc_int(env->CallIntMethodA(mClass, mMethod, jargs));
break;
case jniLong:
result = alloc_int(env->CallLongMethodA(inObject, mMethod, jargs));
break;
case jniFloat:
result = alloc_float(env->CallFloatMethodA(inObject, mMethod, jargs));
break;
case jniDouble:
result = alloc_float(env->CallDoubleMethodA(inObject, mMethod, jargs));
break;
}
CleanStringArgs();
return result;
}
示例2:
Handle<Value> TiAndroidRequeststoragepermissionModule::hasStoragePermission(const Arguments& args)
{
LOGD(TAG, "hasStoragePermission()");
HandleScope scope;
JNIEnv *env = titanium::JNIScope::getEnv();
if (!env) {
return titanium::JSException::GetJNIEnvironmentError();
}
static jmethodID methodID = NULL;
if (!methodID) {
methodID = env->GetMethodID(TiAndroidRequeststoragepermissionModule::javaClass, "hasStoragePermission", "()Z");
if (!methodID) {
const char *error = "Couldn't find proxy method 'hasStoragePermission' with signature '()Z'";
LOGE(TAG, error);
return titanium::JSException::Error(error);
}
}
titanium::Proxy* proxy = titanium::Proxy::unwrap(args.Holder());
jvalue* jArguments = 0;
jobject javaProxy = proxy->getJavaObject();
jboolean jResult = (jboolean)env->CallBooleanMethodA(javaProxy, methodID, jArguments);
if (!JavaObject::useGlobalRefs) {
env->DeleteLocalRef(javaProxy);
}
if (env->ExceptionCheck()) {
Handle<Value> jsException = titanium::JSException::fromJavaException();
env->ExceptionClear();
return jsException;
}
Handle<Boolean> v8Result = titanium::TypeConverter::javaBooleanToJsBoolean(env, jResult);
return v8Result;
}
开发者ID:benbahrenburg,项目名称:Ti-Android-RequestStoragePermission,代码行数:48,代码来源:com.boxoutthinkers.reqstorageperm.TiAndroidRequeststoragepermissionModule.cpp
示例3: call
//.........这里部分代码省略.........
} break;
case Variant::REAL_ARRAY: {
DVector<float> array = *p_args[i];
jfloatArray arr = env->NewFloatArray(array.size());
DVector<float>::Read r = array.read();
env->SetFloatArrayRegion(arr,0,array.size(),r.ptr());
v[i].l=arr;
} break;
default: {
ERR_FAIL_V(Variant());
} break;
}
}
print_line("calling method!!");
Variant ret;
switch(E->get().ret_type) {
case Variant::NIL: {
print_line("call void");
env->CallVoidMethodA(instance,E->get().method,v);
} break;
case Variant::BOOL: {
ret = env->CallBooleanMethodA(instance,E->get().method,v);
print_line("call bool");
} break;
case Variant::INT: {
ret = env->CallIntMethodA(instance,E->get().method,v);
print_line("call int");
} break;
case Variant::REAL: {
ret = env->CallFloatMethodA(instance,E->get().method,v);
} break;
case Variant::STRING: {
jobject o = env->CallObjectMethodA(instance,E->get().method,v);
String singname = env->GetStringUTFChars((jstring)o, NULL );
} break;
case Variant::STRING_ARRAY: {
jobjectArray arr = (jobjectArray)env->CallObjectMethodA(instance,E->get().method,v);
int stringCount = env->GetArrayLength(arr);
DVector<String> sarr;
for (int i=0; i<stringCount; i++) {
jstring string = (jstring) env->GetObjectArrayElement(arr, i);
const char *rawString = env->GetStringUTFChars(string, 0);
sarr.push_back(String(rawString));
}
ret=sarr;
} break;
示例4: call
virtual Variant call(const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error) {
//print_line("attempt to call "+String(p_method));
ERR_FAIL_COND_V(!instance,Variant());
r_error.error=Variant::CallError::CALL_OK;
Map<StringName,MethodData >::Element *E=method_map.find(p_method);
if (!E) {
print_line("no exists");
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
return Variant();
}
int ac = E->get().argtypes.size();
if (ac<p_argcount) {
print_line("fewargs");
r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument=ac;
return Variant();
}
if (ac>p_argcount) {
print_line("manyargs");
r_error.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument=ac;
return Variant();
}
for(int i=0;i<p_argcount;i++) {
if (!Variant::can_convert(p_args[i]->get_type(),E->get().argtypes[i])) {
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument=i;
r_error.expected=E->get().argtypes[i];
}
}
jvalue *v=NULL;
if (p_argcount) {
v=(jvalue*)alloca( sizeof(jvalue)*p_argcount );
}
JNIEnv *env = ThreadAndroid::get_env();
int res = env->PushLocalFrame(16);
ERR_FAIL_COND_V(res!=0,Variant());
//print_line("argcount "+String::num(p_argcount));
List<jobject> to_erase;
for(int i=0;i<p_argcount;i++) {
jvalret vr = _variant_to_jvalue(env, E->get().argtypes[i], p_args[i]);
v[i] = vr.val;
if (vr.obj)
to_erase.push_back(vr.obj);
}
//print_line("calling method!!");
Variant ret;
switch(E->get().ret_type) {
case Variant::NIL: {
//print_line("call void");
env->CallVoidMethodA(instance,E->get().method,v);
} break;
case Variant::BOOL: {
ret = env->CallBooleanMethodA(instance,E->get().method,v);
//print_line("call bool");
} break;
case Variant::INT: {
ret = env->CallIntMethodA(instance,E->get().method,v);
//print_line("call int");
} break;
case Variant::REAL: {
ret = env->CallFloatMethodA(instance,E->get().method,v);
} break;
case Variant::STRING: {
jobject o = env->CallObjectMethodA(instance,E->get().method,v);
String str = env->GetStringUTFChars((jstring)o, NULL );
ret=str;
//.........这里部分代码省略.........
示例5: _call_method
//.........这里部分代码省略.........
argv[i].l=a;
to_free.push_back(a);
}
break;
case ARG_ARRAY_BIT|ARG_TYPE_CLASS: {
argv[i].l=NULL;
}
break;
}
}
r_error.error=Variant::CallError::CALL_OK;
bool success=true;
switch(method->return_type) {
case ARG_TYPE_VOID: {
if (method->_static) {
env->CallStaticVoidMethodA(_class,method->method,argv);
} else {
env->CallVoidMethodA(p_instance->instance,method->method,argv);
}
ret=Variant();
}
break;
case ARG_TYPE_BOOLEAN: {
if (method->_static) {
ret=env->CallStaticBooleanMethodA(_class,method->method,argv);
} else {
ret=env->CallBooleanMethodA(p_instance->instance,method->method,argv);
}
}
break;
case ARG_TYPE_BYTE: {
if (method->_static) {
ret=env->CallStaticByteMethodA(_class,method->method,argv);
} else {
ret=env->CallByteMethodA(p_instance->instance,method->method,argv);
}
}
break;
case ARG_TYPE_CHAR: {
if (method->_static) {
ret=env->CallStaticCharMethodA(_class,method->method,argv);
} else {
ret=env->CallCharMethodA(p_instance->instance,method->method,argv);
}
}
break;
case ARG_TYPE_SHORT: {
if (method->_static) {
ret=env->CallStaticShortMethodA(_class,method->method,argv);
} else {
ret=env->CallShortMethodA(p_instance->instance,method->method,argv);
}
}
break;
case ARG_TYPE_INT: {
示例6: methodSig
//.........这里部分代码省略.........
env->CallVoidMethodA(javaObject, mid, java_params);
} else {
switch (retvalInfo->GetType().TagPart())
{
case nsXPTType::T_I8:
retval.b = env->CallByteMethodA(javaObject, mid, java_params);
break;
case nsXPTType::T_I16:
case nsXPTType::T_U8:
retval.s = env->CallShortMethodA(javaObject, mid, java_params);
break;
case nsXPTType::T_I32:
case nsXPTType::T_U16:
retval.i = env->CallIntMethodA(javaObject, mid, java_params);
break;
case nsXPTType::T_I64:
case nsXPTType::T_U32:
retval.j = env->CallLongMethodA(javaObject, mid, java_params);
break;
case nsXPTType::T_FLOAT:
retval.f = env->CallFloatMethodA(javaObject, mid, java_params);
break;
case nsXPTType::T_U64:
case nsXPTType::T_DOUBLE:
retval.d = env->CallDoubleMethodA(javaObject, mid, java_params);
break;
case nsXPTType::T_BOOL:
retval.z = env->CallBooleanMethodA(javaObject, mid, java_params);
break;
case nsXPTType::T_CHAR:
case nsXPTType::T_WCHAR:
retval.c = env->CallCharMethodA(javaObject, mid, java_params);
break;
case nsXPTType::T_CHAR_STR:
case nsXPTType::T_WCHAR_STR:
case nsXPTType::T_IID:
case nsXPTType::T_ASTRING:
case nsXPTType::T_DOMSTRING:
case nsXPTType::T_UTF8STRING:
case nsXPTType::T_CSTRING:
case nsXPTType::T_INTERFACE:
case nsXPTType::T_INTERFACE_IS:
retval.l = env->CallObjectMethodA(javaObject, mid, java_params);
break;
case nsXPTType::T_VOID:
retval.j = env->CallLongMethodA(javaObject, mid, java_params);
break;
default:
NS_WARNING("Unhandled retval type");
break;
}
}
// Check for exception from called Java function
jthrowable exp = env->ExceptionOccurred();
if (exp) {