bool stopSDK() { JniMethodInfo mi; bool isHave = getMethod(mi, "stopSDK", "()V"); if (!isHave) { return false; } mi.env->CallStaticVoidMethod(mi.classID, mi.methodID); releaseMethod(mi); return true; }
bool showUser(int platformId, C2DXGetUserInfoResultEvent callback){ JniMethodInfo mi; bool isHave = getMethod(mi, "showUser", "(I)V"); if (!isHave) { return false; } mi.env->CallStaticVoidMethod(mi.classID, mi.methodID, platformId); releaseMethod(mi); infoCb = callback; return true; }
bool isValid(int platformId) { JniMethodInfo mi; bool isHave = getMethod(mi, "isValid", "(I)Z"); if (!isHave) { return false; } jboolean valid = mi.env->CallStaticBooleanMethod(mi.classID, mi.methodID, platformId); releaseMethod(mi); return valid == JNI_TRUE; }
bool removeAccount(int platformId) { JniMethodInfo mi; bool isHave = getMethod(mi, "removeAccount", "(I)V"); if (!isHave) { return false; } mi.env->CallStaticVoidMethod(mi.classID, mi.methodID, platformId); releaseMethod(mi); return true; }
bool FeiyuSdkHelper::doExitGame() { JniMethodInfo mi; jboolean hasExitDialog = false; bool isHave = getMethod(mi, "doExitGame", "()Z"); if (isHave) { hasExitDialog = mi.env->CallStaticBooleanMethod(mi.classID, mi.methodID); releaseMethod(mi); } return hasExitDialog; }
bool doAuthorize(int platformId, C2DXAuthResultEvent callback) { JniMethodInfo mi; bool isHave = getMethod(mi, "authorize", "(I)V"); if (!isHave) { return false; } mi.env->CallStaticVoidMethod(mi.classID, mi.methodID, platformId); releaseMethod(mi); authCb = callback; return true; }
bool initShareSDK(const char* appKey, bool useAppTrusteeship) { JniMethodInfo mi; bool isHave = getMethod(mi, "initSDK", "(Ljava/lang/String;Z)V"); if (!isHave) { return false; } jstring appKeyStr = mi.env->NewStringUTF(appKey); mi.env->CallStaticVoidMethod(mi.classID, mi.methodID, appKeyStr, useAppTrusteeship); releaseMethod(mi); return true; }
void ShareRec::setOnRecorderStateListener(OnRecorderStateListener listener) { jobject javaRecorder = getRecorder(); if (javaRecorder != NULL) { JniMethodInfo mi; bool res = getMethod(mi, "setOnRecorderStateListener", "(I)V"); if (res) { // retain(listener); mi.env->CallVoidMethod(javaRecorder, mi.methodID, (jint) listener); releaseMethod(mi); } } }
void ShareRec::setText(const char* text) { jobject javaRecorder = getRecorder(); if (javaRecorder != NULL) { JniMethodInfo mi; bool res = getMethod(mi, "setText", "(Ljava/lang/String;)V"); if (res) { jstring jText = mi.env->NewStringUTF(text); mi.env->CallVoidMethod(javaRecorder, mi.methodID, jText); releaseMethod(mi); } } }
void ShareRec::addCustomAttr(const char* key, const char* value) { jobject javaRecorder = getRecorder(); if (javaRecorder != NULL) { JniMethodInfo mi; bool res = getMethod(mi, "addAttrData", "(Ljava/lang/String;Ljava/lang/String;)V"); if (res) { jstring jKey = mi.env->NewStringUTF(key); jstring jValue = mi.env->NewStringUTF(value); mi.env->CallVoidMethod(javaRecorder, mi.methodID, jKey, jValue); releaseMethod(mi); } } }
bool ShareRec::isAvailable() { jobject javaRecorder = getRecorder(); if (javaRecorder != NULL) { JniMethodInfo miIsAvailable; bool res = getMethod(miIsAvailable, "isAvailable", "()Z"); if (res) { jboolean jAvailable = miIsAvailable.env->CallBooleanMethod(javaRecorder, miIsAvailable.methodID); releaseMethod(miIsAvailable); return (JNI_TRUE == jAvailable); } } return false; }
string FeiyuSdkHelper::getFYDataDeviceId() { string deviceId = ""; JniMethodInfo mi; bool isHave = getMethod(mi, "getFYDataDeviceId", "()Ljava/lang/String;"); if (isHave) { jstring jstr_value = (jstring)mi.env->CallStaticObjectMethod(mi.classID, mi.methodID); deviceId = cocos2d::JniHelper::jstring2string(jstr_value); mi.env->DeleteLocalRef(jstr_value); releaseMethod(mi); } return deviceId; }
void FeiyuSdkHelper::doUpdateRole(const char* roleId, const char* roleLv) { JniMethodInfo mi; bool isHave = getMethod(mi, "doUpdateRole", "(Ljava/lang/String;Ljava/lang/String;)V"); if (isHave) { jstring roleId_content = mi.env->NewStringUTF(roleId); jstring roleLv_content = mi.env->NewStringUTF(roleLv); mi.env->CallStaticVoidMethod(mi.classID, mi.methodID, roleId_content, roleLv_content); mi.env->DeleteLocalRef(roleId_content); mi.env->DeleteLocalRef(roleLv_content); releaseMethod(mi); } }
bool setPlatformDevInfo(int platformId, CCDictionary *info) { JniMethodInfo mi; bool isHave = getMethod(mi, "setPlatformConfig", "(ILjava/lang/String;)V"); if (!isHave) { return false; } CCJSONConverter* json = CCJSONConverter::sharedConverter(); const char* ccInfo = json->strFrom(info); jstring jInfo = mi.env->NewStringUTF(ccInfo); // free(ccInfo); mi.env->CallStaticVoidMethod(mi.classID, mi.methodID, platformId, jInfo); releaseMethod(mi); return true; }
bool doShare(int platformId, CCDictionary *content, C2DXShareResultEvent callback){ JniMethodInfo mi; bool isHave = getMethod(mi, "share", "(ILjava/lang/String;)V"); if (!isHave) { return false; } CCJSONConverter* json = CCJSONConverter::sharedConverter(); const char* ccContent = json->strFrom(content); jstring jContent = mi.env->NewStringUTF(ccContent); // free(ccContent); mi.env->CallStaticVoidMethod(mi.classID, mi.methodID, platformId, jContent); releaseMethod(mi); shareCb = callback; return true; }
void FeiyuSdkHelper::doPay(const char* amount, const char* coinType, const char* ExtStr, const char* notifyUrl, const char* orderId, const char* productId, const char* productName, const char* roleId, const char* roleLv, const char* roleName, const char* serverId, const char* serverName, const char* userId, const char* userName, const char* vipLv) { JniMethodInfo mi; const char* signature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"; bool isHave = getMethod(mi, "doPay", signature); if (isHave) { jstring amount_content = mi.env->NewStringUTF(amount); jstring coinType_content = mi.env->NewStringUTF(coinType); jstring ExtStr_content = mi.env->NewStringUTF(ExtStr); jstring notifyUrl_content = mi.env->NewStringUTF(notifyUrl); jstring orderId_content = mi.env->NewStringUTF(orderId); jstring productId_content = mi.env->NewStringUTF(productId); jstring productName_content = mi.env->NewStringUTF(productName); jstring roleId_content = mi.env->NewStringUTF(roleId); jstring roleLv_content = mi.env->NewStringUTF(roleLv); jstring roleName_content = mi.env->NewStringUTF(roleName); jstring serverId_content = mi.env->NewStringUTF(serverId); jstring serverName_content = mi.env->NewStringUTF(serverName); jstring userId_content = mi.env->NewStringUTF(userId); jstring userName_content = mi.env->NewStringUTF(userName); jstring vipLv_content = mi.env->NewStringUTF(vipLv); mi.env->CallStaticVoidMethod(mi.classID, mi.methodID, amount_content, coinType_content, ExtStr_content, notifyUrl_content, orderId_content, productId_content, productName_content, roleId_content, roleLv_content, roleName_content, serverId_content, serverName_content, userId_content, userName_content, vipLv_content); mi.env->DeleteLocalRef(amount_content); mi.env->DeleteLocalRef(coinType_content); mi.env->DeleteLocalRef(ExtStr_content); mi.env->DeleteLocalRef(notifyUrl_content); mi.env->DeleteLocalRef(orderId_content); mi.env->DeleteLocalRef(productId_content); mi.env->DeleteLocalRef(productName_content); mi.env->DeleteLocalRef(roleId_content); mi.env->DeleteLocalRef(roleLv_content); mi.env->DeleteLocalRef(roleName_content); mi.env->DeleteLocalRef(serverId_content); mi.env->DeleteLocalRef(serverName_content); mi.env->DeleteLocalRef(userId_content); mi.env->DeleteLocalRef(userName_content); mi.env->DeleteLocalRef(vipLv_content); releaseMethod(mi); } }
void ShareRec::listLocalVideos(jlong** list, int* len) { jobject javaRecorder = getRecorder(); if (javaRecorder != NULL) { JniMethodInfo mi; bool res = getMethod(mi, "listLocalVideos", "()[J"); if (res) { jlongArray ids = (jlongArray) mi.env->CallObjectMethod(javaRecorder, mi.methodID); releaseMethod(mi); len[0] = mi.env->GetArrayLength(ids); jlong* clist = mi.env->GetLongArrayElements(ids, JNI_FALSE); jlong* tmp = (jlong*) malloc(sizeof(jlong) * len[0]); for (int i = 0; i < len[0]; i++) { tmp[i] = clist[i]; } mi.env->ReleaseLongArrayElements(ids, clist, JNI_FALSE); list[0] = tmp; } } }