问题
I'm trying to integrate AdWhirl and AdMob in my Android Application and I have some question:
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; 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
I already put also this code in 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" />
- 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.
回答1:
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. You could get away with wrapping the content of the AdWhirlLayout you define in XML. You will need to have an AdWhirlLayout in each activity that you want to display ads in, however.
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.
来源:https://stackoverflow.com/questions/7594563/android-integration-adwhirl-and-admob