public void initAdWhirl() { setContentView(R.layout.main); AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5); AdWhirlLayout adWhirlLayout = (AdWhirlLayout) findViewById(R.id.adwhirl_layout); TextView textView = new TextView(this); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); int diWidth = 320; int diHeight = 52; int density = (int) getResources().getDisplayMetrics().density; try { adWhirlLayout.setAdWhirlInterface(this); adWhirlLayout.setMaxWidth((int) (diWidth * density)); adWhirlLayout.setMaxHeight((int) (diHeight * density)); layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); textView.setText("Below AdWhirlLayout"); // LinearLayout layout = (LinearLayout)findViewById(R.id.layout_main); RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout_main); if (layout == null) { Log.e("AdWhirl", "Layout is null!"); return; } // layout.setGravity(Gravity.CENTER_HORIZONTAL); // layout.addView(adWhirlLayout, layoutParams); // layout.addView(textView, layoutParams); layout.invalidate(); } catch (Exception e) { Log.e("ADWHIRL", "Error in code:" + e.toString()); e.printStackTrace(); } AdWhirlAdapter.setGoogleAdSenseAppName("OpenMBTA"); AdWhirlAdapter.setGoogleAdSenseCompanyName("Kaja Software"); // AdWhirlAdapter.setGoogleAdSenseChannel("xxxxxxx"); // AdWhirlTargeting.setKeywords("My keywords"); }