简体   繁体   English

Android整合AdWhirl和AdMob

[英]Android integration AdWhirl and AdMob

I'm trying to integrate AdWhirl and AdMob in my Android Application and I have some question: 我正在尝试将AdWhirl和AdMob集成到我的Android应用程序中,但我有一个问题:

  1. I have many activities and I want put advertisement in most of them. 我有很多活动,我想在大多数活动中放广告。 In which activity should I put the following code? 我应该在以下活动中输入以下代码?

    // ** *ADWHIRL CODE // These are density-independent pixel units, as defined in // http://developer.android.com/guide/practices/screens_support.html int width = 320; // ** * ADWHIRL代码//这是与密度无关的像素单位,如// http://developer.android.com/guide/practices/screens_support.html int width = 320; int height = 52; 整型高度= 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 

I already put also this code in AndroidManifest: 我已经将此代码也放入了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" />
  1. Is it possible show the ads always in the foreground, in a indipendent way from the height of the content? 是否有可能以与内容高度无关的方式始终在前景中展示广告?

Does anyone have any advice? 有人有建议吗? Any help is appreciated. 任何帮助表示赞赏。 Sorry for my English. 对不起我的英语不好。

While the code at the top is nice to make sure your AdWhirlLayout doesn't extend upon the dimensions of the screen, you shouldn't need to include that at all. 虽然最上面的代码可以确保您的AdWhirlLayout不在屏幕尺寸上扩展,但您根本不需要添加该代码。 You could get away with wrapping the content of the AdWhirlLayout you define in XML. 您可以将XML中定义的AdWhirlLayout的内容包装起来。 You will need to have an AdWhirlLayout in each activity that you want to display ads in, however. 但是,您要在其中展示广告的每个活动中都需要有一个AdWhirlLayout。

To show your ads in the same place regardless of content, consider using a RelativeLayout and using the android:layout_alignParentBottom="true" property in your AdWhirlLayout to assign the ad to the bottom of the screen, for example. 要在相同位置展示广告,而不管其内容如何,​​请考虑使用RelativeLayout并在android:layout_alignParentBottom="true"使用android:layout_alignParentBottom="true"属性将广告分配到屏幕底部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM