我找到了与Android.But集成的RevMob文档,因为我使用LibGDX作为我的框架我完全不知道怎么做。我确实找到了一种集成AdMob的方法。但这是一个横幅广告,我希望全屏RevMob添加。 Here是RevMob Docs的链接。有人请简要告诉我如何在LibGDX中实现它?
答案 0 :(得分:0)
尝试在主LibGDX项目中创建一个接口,并在你的android项目中实现它,就像这样....
import android.content.Context;
import android.util.Log;
import com.revmob.RevMob;
import com.revmob.RevMobAdsListener;
import com.revmob.ads.fullscreen.RevMobFullscreen;
public class RevMobDisplay implements AdInterface{
public RevMobAdsListener listener;
private RevMobFullscreen fullscreen;
private MainActivity activity;
private RevMob revmob;
public RevMobDisplay(MainActivity mainActivity){
this.activity = mainActivity;
revmob = RevMob.start(activity);
//UNCOMMENT THIS CODE AFTER YOU HAVE PUBLISHED YOUR GAME LIVE
//USE WHILE TESTING YOUR GAME DURING DEVELOPMENT
revmob.setTestingMode(RevMobTestingMode.WITH_ADS);
listener = new RevMobAdsListener() {
@Override
public void onRevMobAdDisplayed() {
Log.i("[RevMob]", "onAdDisplayed");
}
@Override
public void onRevMobAdReceived() {
Log.i("[RevMob]", "onAdReceived");
}
@Override
public void onRevMobAdNotReceived(String message) {
Log.i("[RevMob]", "onAdNotReceived");
}
@Override
public void onRevMobAdDismiss() {
Log.i("[RevMob]", "onAdDismiss");
fullscreen.hide();
}
@Override
public void onRevMobAdClicked() {
Log.i("[RevMob]", "onAdClicked");
revmob.openAdLink(activity, "6753b82ad690ad146c233a6d",this);
}
};
// Pre-load it without showing it
fullscreen = revmob.createFullscreen(activity, "6753b82ad690ad146c233a6d", listener);
revmob.setTimeoutInSeconds(5);
}
@Override
public void showAds(boolean show) {
if(show){
if(fullscreen == null)
fullscreen = revmob.createFullscreen(activity, "6753b82ad690ad146c233a6d", listener);
fullscreen.show();
}
else{
fullscreen.hide();
}
}
}
现在您已经实现了所有内容......将主项目的默认构造函数更改为类似
的内容initialize(new MyGame(new RevMobDisplay(this)), cfg);
现在,您可以通过调用
轻松地在游戏中展示广告MyGame.revmobAdInterface.showAds(true);
在此处找到有关将revmob与libgdx集成的详细教程