I've tried to make a test app to see how admob works. But almost every time "No ad to show". Here is my source code:
public voi开发者_开发技巧d onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AdView adView = new AdView(this, AdSize.BANNER, "xxxxxxxxxxxxxxxxx");
adView.setAdListener(this);
LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);
layout.addView(adView);
adView.loadAd(new AdRequest());
}
but in a hour, it appeared only once. Am I doing something wrong?
It works fine but you should wait for a moment at the first time , if you want just to test you can use the test mode by adding this line (new AdRequest()).setTesting(true);
Make sure that you are using the general key and not the debug key for the AdMob API
精彩评论