Using Chartboost with andengine for showing adds in a game

425 views Asked by At

can anybody tell me how can i configure the Chart boost add platform in an And engine game to show add's in the game. i have downloaded the chartboost sdk and i am trying to configure the ChartBoost in onCreateEngineOption like -

public EngineOptions onCreateEngineOptions()
    {
        camera = new BoundCamera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
        EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new FillResolutionPolicy(), this.camera);
        engineOptions.getAudioOptions().setNeedsMusic(true).setNeedsSound(true);//turn on the music and sound option
        engineOptions.getRenderOptions().getConfigChooserOptions().setRequestedMultiSampling(true);
        engineOptions.setWakeLockOptions(WakeLockOptions.SCREEN_ON);//tell the engine to always keep the screen unloced while game is running
        engineOptions.getRenderOptions().setDithering(true);//enable the Dithering for the whole game by default
        return engineOptions;

        // Configure Chartboost
        this.cb = Chartboost.sharedChartboost();
        String appId = "YOUR_APP_ID";
        String appSignature = "YOUR_APP_SIGNATURE";
        this.cb.onCreate(this, appId, appSignature, null);
    }

and my game is crashing... Thanks !!!

2

There are 2 answers

0
Shyam Vishwakarma On BEST ANSWER

I have figured it out how to Integrate the Chartboost in an Andengine Game by myself

Step 1) Initialize the Chartboost in OnCreateEngineOption

//ChrtBoost Code
    cb = Chartboost.sharedChartboost();
    String appId = "****************";
    String appSignature = "****************************";
    cb.onCreate(this,appId,appSignature, null);
    cb.onStart(this);
    cb.setImpressionsUseActivities(true);   
    //end of chartBoost Code

Step 2) Start Session in onCreateResource Method

this.runOnUiThread(new Runnable() {
        public void run() {

            cb.startSession();
            cb.showInterstitial(); 

              }
    });

Step 3 Caching the add's initially use onCreateScene Method

//cache the adds initially
    this.cb.cacheInterstitial();

Step 4 to show add in your scene call following method

cb.showInterstitial();
0
Plastic Sturgeon On

Chartboost expects to be added to a view in standard android Activity, not as part of andengine. You should use a SimpleLayoutGameActivity as your game activity so that you can provide an XML layout for your ad service.

Take a look at the XMLLayoutExample (https://code.google.com/p/andengineexamples/source/browse/src/org/anddev/andengine/examples/XMLLayoutExample.java)

Or take a look at this old implementation I made using andengine GLES1 a while back. The needs will be similar. This uses AdMob instead of Chartboost, but the reason your app is crashing is the same: You need to use a custom XMLlayout to make your ad serving work.

https://github.com/zfoley/AndengineAdmobLayoutExample

Hope this gets you on the right track!