我试图在我的Android应用程序中集成AdWhirl和AdMob,我有一些问题:
-
我有很多活动,我想在大多数活动中放广告。我应该把以下代码放在哪个活动中?
// * * * ADWHIRL代码//这些是与密度无关的像素单位,定义在//http://developer.android.com/guide/practices/screens_support.htmlInt width = 320;Int height = 52;
DisplayMetrics displayMetrics = getResources().getDisplayMetrics(); float density = displayMetrics.density; width = (int) (width * density); height = (int) (height * density); // Optional, will fetch new config if necessary after five minutes. AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5); // References AdWhirlLayout defined in the layout XML. AdWhirlLayout adWhirlLayout = (AdWhirlLayout) findViewById(R.id.adwhirl_layout); adWhirlLayout.setAdWhirlInterface(this); adWhirlLayout.setMaxWidth(width); adWhirlLayout.setMaxHeight(height); //*******ADWHIRL CODE END
我已经把这段代码也放在AndroidManifest:
<!-- AdWhirl Key -->
<meta-data android:value="7e*********************5a6"
android:name="ADWHIRL_KEY" />
<!-- AdMob integration -->
<activity android:name="com.google.ads.AdActivity"
android:configChanges="orientation|keyboard|keyboardHidden" />
- 是否有可能显示广告总是在前景,以一种独立的方式从内容的高度?
有人有什么建议吗?任何帮助都是感激的。对不起,我的英语不好。
虽然顶部的代码很好地确保您的AdWhirlLayout不会在屏幕的尺寸上扩展,但您根本不需要包含它。您可以将用XML定义的AdWhirlLayout的内容打包。但是,您需要在每个想要显示广告的活动中都有一个AdWhirlLayout。
要在同一位置显示广告,无论内容如何,请考虑使用RelativeLayout和
android:layout_alignParentBottom="true"
属性分配广告到屏幕的底部,例如。