参考珊瑚SDK,jni的调用方式
extern"C"{#if(CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID)voidJava_com_friendou_Interface_coralsdk_SendtoGame(JNIEnv*env,jobjectthiz,jstringinfo){constchar*temp=env->GetStringUTFChars(info,NULL);if(gSDKCallback==NULL||p!=NULL){__android_log_print(ANDROID_LOG_INFO,"SDKCallbackError","ThegSDKCallbackpointerisnull!");return;}FMJSONDictionary*Recivejson=newFMJSONDictionary();Recivejson->initWithDescription(temp);//__android_log_print(ANDROID_LOG_INFO,"SDKCallback","SDKCallbackmessage=%s",temp);constchar*ReciveAction=Recivejson->getItemStringFMValue("action");if(strcmp(ReciveAction,"1001")==0){charconst*userlist=Recivejson->getItemStringFMValue("userlist");__android_log_print(ANDROID_LOG_INFO,"Test","userlist=%s",userlist);GameUserSelectedNotification(userlist);//userlisttReturn.c_str()}elseif(strcmp(ReciveAction,"1002")==0){//charconst*userlist=Recivejson->getItemStringFMValue("userlist");//GameReplayNotification(userlist);}elseif(strcmp(ReciveAction,"1003")==0){__android_log_print(ANDROID_LOG_INFO,"Test","LogoutNotify1003");LogoutNotify();}elseif(strcmp(ReciveAction,"1004")==0){boolisOn=Recivejson->getItemBoolFMvalue("isOn",false);MusicTurnOffAndOn(isOn);}elseif(strcmp(ReciveAction,"1005")==0){boolisOn=Recivejson->getItemBoolFMvalue("isOn",false);SoundTurnOffAndOn(isOn);}elseif(strcmp(ReciveAction,"1006")==0){intaisLogin=Recivejson->getItemIntFMValue("isLogin",0);LoginResult(aisLogin);__android_log_print(ANDROID_LOG_INFO,"Test","LoginResult1006=%d",aisLogin);}elseif(strcmp(ReciveAction,"1007")==0){__android_log_print(ANDROID_LOG_INFO,"Test","GameBackNotification1007");GameBackNotification();}elseif(strcmp(ReciveAction,"1008")==0){//ApplicationWillResignActive();}else{__android_log_print(ANDROID_LOG_INFO,"SDKCallbackError","Havenothiscallback!");return;}}#endif}
珊瑚SDK官方调用例子,可以下载来看看哦,对于Android开发接入jni还是有很大的帮助
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。