Hello,
I am trying to integrate Chartboost in my Android Native Corona App since I am using Enterprise version of Corona.
Making the interstitial banner from Chartboost to appear is not big deal, we only need to initialize it and then show it. My problem is that before showing it I need to check for a global var from the lua state to make my decision, this global var indicates if the game is active or not, this way I can prevent the interstitial ad from appearing in the middle of the game and annoying the players.
I implemented the module chartboost and the lua call is “chartboost.showInterstitial()”. This ends in following java class which implements this function:
public class ChartboostShowInterstitialLuaFunction implements com.naef.jnlua.NamedJavaFunction {
@Override
public String getName() {
return “showInterstitial”;
}
@Override
public int invoke(com.naef.jnlua.LuaState luaState) {
com.ansca.corona.CoronaActivity activity = com.ansca.corona.CoronaEnvironment.getCoronaActivity();
com.chartboost.sdk.ChartBoost cb = com.chartboost.sdk.ChartBoost.getSharedChartBoost(activity);
android.util.Log.d(“Corona”, “SHOW INTERSTITIAL”);
cb.setDelegate(new ChartboostDelegateWithLuaState(luaState));
cb.showInterstitial();
return 0;
}
}
The invoke method do updates the charboost’s context referencing by giving to it the current CoronaActivity, then it sets a Delegate for chartboost from class ChartboostDelegateWithLuaState:
public class ChartboostDelegateWithLuaState extends com.chartboost.sdk.ChartBoostDelegate {
private com.naef.jnlua.LuaState luaState;
public ChartboostDelegateWithLuaState(com.naef.jnlua.LuaState luaState) {
super();
this.luaState = luaState;
}
public boolean shouldDisplayInterstitial(android.view.View interstitialView) {
this.luaState.getGlobal(“gameIsActive”);
boolean gameIsActive = luaState.checkBoolean(-1);
android.util.Log.d(“Corona”, "gameIsActive = " + String.valueOf(gameIsActive));
return !gameIsActive;
}
}
This delegates needs to implement method shouldDisplayInterstitial as the Chartboost’s documentation suggests that gets called before showing the interstitial ad, if I return false in this method the interstitial is not shown. This is where my problem occurs: the global gameIsActive seams to be always false, but the game updates it just after the game starts, which makes me believe the luaState objects needs to be updated in some way to reflect the new value of global var gameIsActive.
Is there a way to perform this update of luaState? Is there any other way of implementing this?
Thanks in advance for any help.
Best regards,
Augusto Souza [import]uid: 133680 topic_id: 32703 reply_id: 332703[/import]