The following code is what I implemented just to check admob ads retrieval but I couldn’t get any ads although the code is even no crashing.
Please inform what is wrong in this code.
public class MainActivity extends Activity {
public AdView admobView;
public View mainView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
admobView = new AdView(this, AdSize.BANNER, "Top secret");
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
admobView.setLayoutParams(lp);
//mainView.setLayoutParams(lp);
RelativeLayout layout = new RelativeLayout(this);
AdRequest adRequest = new AdRequest();
//tested this
adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // Emulator
//tested this
//adRequest.addTestDevice("20cb18e8ffc74ad2");
//tested this
//adRequest.addMediationExtra("3d879f364d5747c5", null);
admobView.loadAd(adRequest);
layout.addView(admobView);
//layout.addView(mainView);
setContentView(layout);
}
Did you add permissions and congifchanges of admob in your menifest. Cause i have run your code and it displayed in my emulator. And also in order to display add your app’s targetSdkVersion need to be greater then 14.
Activity is as like you
And Manifest is ==