Cocos2dx platform Interconnection (Amazon IAP, Chartboost, Email)
The main purpose is to forget. If you are lucky enough to help other friends, it is better that my game uses cocos2dx 2.2.5. Of course, 2.1.x ~ is used ~ Version 2.2.5 is acceptable and remains unchanged. 1. Java calls C ++ 1. Declare a static function with "native" in the JAVA Project, for example (assuming the package name is com. ooxx. mygame class MyActivity {... Public static native int onIAPCallback (int select );...} In a JAVA project, you can call this function as a normal static function. 2. Open main. cpp: Write jint Java_com_ooxx_mygame_MyActivity_onIAPCallback (JNIEnv * env, jobject thiz, jint select) according to the functions in it) {// call your C ++ code} II. C ++ calls JAVA 1. Declare a common static function in the JAVA Project, for example (assuming the package name is com. ooxx. mygame class MyActivity {... Public static void onBuySomething (int itemID) {// do what you want to do }...} 2. In the C ++ project, call this function // contains JniHelper. h # if (CC_TARGET_PLATFORM = CC_PLATFORM_ANDROID) # include "platform/android/jni/JniHelper. h "# endif // call the static function in JAVA # elif (CC_TARGET_PLATFORM = CC_PLATFORM_ANDROID) JniMethodInfo t; if (JniHelper: getStaticMethodInfo (t, "com/ooxx/mygame/MyActivity", "onBuySomething", "(I) V") {t. env-> CallStaticVoidMethod (t. classID, t. methodID, itemID); t. env-> DeleteLocalRef (t. clas SID) ;}# endif // The AndroidJNI instruction is attached here. Please go here to answer your questions. 3. Click a button to open the email on the player's machine and invite you as a friend, game feedback and other public static void sendEmail (String sendTo, String subject, String body) {Intent email = new Intent (android. content. intent. ACTION_SEND); email. setType ("plain/text"); String [] emailReciever = new String [] {sendTo}; email. putExtra (android. content. intent. EXTRA_EMAIL, emailReciever); email. putExtra (android. content. intent. EXTRA_SUBJECT, subject); email. putExtra (android. content. intent. EXTRA_TEXT, body); GameActivity. self. startActivity (Intent. createChooser (email, "Choose Email Client");} 4. Open the Amazon store public static void onOpenInMarketClient (String id) {Intent intent = new Intent (Intent. ACTION_DEFAULT); Uri content_url = Uri. parse ("amzn: // apps/android? Asin = "+ id); intent. setData (content_url); GameActivity. Self. startActivity (intent );}