Embedded advertisement in Cocos2d-x game)

Source: Internet
Author: User

1. Declare Activity

<! -- Declare Baidu's activity --> <meta-data Android: Name = "baidumobad_app_id" Android: value = "debug"/> <meta-data Android: Name = "baidumobad_app_sec" Android: value = "debug"/> <activity Android: Name = "com. baidu. mobads. appactivity "Android: configchanges =" keyboard | keyboardhidden | orientation "/>


 

2. In the main activity class, the initial advertisement object

Interad = new interstitialad (this); interad. setlistener (New interstitialadlistener () {@ overridepublic void onadclick (interstitialad arg0) {log. I ("interstitialad", "onadclick") ;}@ overridepublic void onaddismissed () {log. I ("interstitialad", "onaddismissed"); interad. loadad () ;}@ overridepublic void onadfailed (string arg0) {log. I ("interstitialad", "onadfailed") ;}@ overridepublic void onadpresent () {log. I ("interstitialad", "onadpresent") ;}@ overridepublic void onadready () {log. I ("interstitialad", "onadready") ;}}); // load the advertisement interad. loadad ();

3. Display Advertisement

Handler = new handler () {@ overridepublic void handlemessage (Message MSG) {// todo auto-generated method stubswitch (MSG. what) {Case 3: // public void onclick (view arg0) {If (interad. isadready () {// check whether the log is successfully read. I ("interstitialad", "showad"); interad. showad (test. this); // display} else {interad. loadad (); log. I ("interstitialad", "loadad... ") ;}break ;}}};


4. Define static functions for calling CPP

public static void showInterstitialStatic() {Message msg = handler.obtainMessage();msg.what = 3;handler.sendMessage(msg);}


5. Click Show.


 

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.