Game Development Reference
In-Depth Information
layout.addView(av);
//displays ads at the bottom
layout.setGravity(Gravity.BOTTOM);
//sends a generic request to load ads
AdRequest request = new AdRequest();
request.setTesting( true );
Set<String> keywords = new HashSet<String>();
keywords.add( "android game" );
request.setKeywords(keywords);
av.loadAd(request);
}
catch (Exception e){}
}
Step 7: Calling showAds() method
Call showAds() method in the main activity:
Handler myHandler = new Handler(){
public void handleMessage(Message msg) {
switch (msg.what){
case 4: //game
setContentView(gv);
currentView = gv;
//displays ads
showAds();
pv = null ;
break ;
............
}
}
}
That's it! Now you can run your app and see how the Admob ads show up in it (figure
7.18).
Search WWH ::




Custom Search