Cocos2dx platform Interconnection (Amazon IAP, Chartboost, Email)

Source: Internet
Author: User

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 );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.