0
我遇到Admob廣告根本沒有顯示的問題,我認爲我做了一切正確的事情,但他們仍然不會顯示。 我正在尋找代碼試圖找到任何錯誤,但沒有看起來錯了 請任何solits?!Admob廣告根本沒有顯示
這裏的MainActivity.java:
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.google.ads.Ad;
import com.google.ads.AdListener;
import com.google.ads.AdRequest;
import com.google.ads.AdRequest.ErrorCode;
import com.google.ads.InterstitialAd;
public class MainActivity extends AndroidApplication implements
AdListener {
private ActionResolverAndroid actionResolverAndroid;
private InterstitialAd interstitialAdMob;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
interstitialAdMob = new InterstitialAd(MainActivity.this,"ca-app-pub-3940256099942544/1033173712");
interstitialAdMob.setAdListener(this);
interstitialAdMob.loadAd(new AdRequest());
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.useWakelock = true;
cfg.useGL20 = false;
actionResolverAndroid = new ActionResolverAndroid(this,
startAppInterHandler);
View v = initializeForView(new JetPig(actionResolverAndroid), cfg);
setContentView(v);
}
private boolean startAppExit;
public Handler startAppInterHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
// if (startAppAd.isReady())
//
// {
switch (msg.what) {
case 1:
if (interstitialAdMob.isReady())
interstitialAdMob.show(); // show the ad
else
interstitialAdMob.loadAd(new AdRequest()); // load the next ad
break;
case 2:
if (interstitialAdMob.isReady()) {
interstitialAdMob.show();
startAppExit = true;
} else
finish();
default:
break;
}
Gdx.app.log("Add", "In ShowStartApp Hanlder");
// }
}
};
public boolean isNetworkAvailable() {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager
.getActiveNetworkInfo();
return activeNetworkInfo != null;
}
public void finishActivity() {
finish();
}
@Override
public void onStart() {
super.onStart();
}
@Override
public void onStop() {
super.onStop();
}
@Override
public void onDismissScreen(Ad arg0) {
// TODO Auto-generated method stub
if (startAppExit) {
Gdx.app.log("Add", "Finsh");
finish();
}
else
{
interstitialAdMob.loadAd(new AdRequest());
}
}
@Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
// TODO Auto-generated method stub
}
@Override
public void onLeaveApplication(Ad arg0) {
// TODO Auto-generated method stub
}
@Override
public void onPresentScreen(Ad arg0) {
// TODO Auto-generated method stub
}
@Override
public void onReceiveAd(Ad arg0) {
// TODO Auto-generated method stub
}
}
我試了一下,但還是一無所有 –
轉到鏈接 – Aryan